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 ( n == 1 || n == 0 ) ? 1 : n * f_gold ( n - 1 ); }
[]
null
[]
EULERIAN_NUMBER_1
python
[]
def f_gold ( n , m ) : dp = [ [ 0 for x in range ( m + 1 ) ] for y in range ( n + 1 ) ] for i in range ( 1 , n + 1 ) : for j in range ( 0 , m + 1 ) : if ( i > j ) : if ( j == 0 ) : dp [ i ] [ j ] = 1 else : dp [ i ] [ j ] = ( ( ( i - j ) * dp [ i - 1 ] [ j - 1 ] ) + ( ( j + 1 ) * dp [ i - 1 ] [ j ] ) ) return dp [ n ] [ m ]
code_translation
[ [ "27, 7", "940744845942385425654976" ], [ "77, 34", "6659628962352540071013461802622903732181448311622532437589102727552487005433977695399091580931215833915283931140" ], [ "35, 22", "35713299412878610033189961245712022360" ], [ "26, 20", "131921922645609200622" ], [ ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int x ) { if ( x == 0 || x == 1 ) return x; int start = 1, end = x, ans; while ( start <= end ) { int mid = ( start + end ) / 2; if ( mid * mid == x ) return mid; if ( mid * mid < x ) { start = mid + 1; ans = mid; } else end = mid - 1; } return ans; }
[]
null
[]
MINIMUM_SWAPS_REQUIRED_BRING_ELEMENTS_LESS_EQUAL_K_TOGETHER
python
[]
def f_gold ( arr , n , k ) : count = 0 for i in range ( 0 , n ) : if ( arr [ i ] <= k ) : count = count + 1 bad = 0 for i in range ( 0 , count ) : if ( arr [ i ] > k ) : bad = bad + 1 ans = bad j = count for i in range ( 0 , n ) : if ( j == n ) : break if ( arr [ i ] > k ) : bad = bad - 1 if ( arr [ j ] > k ) : bad = bad + 1 ans = min ( ans , bad ) j = j + 1 return ans
code_translation
[ [ "[7, 12, 15, 30, 33, 34, 53, 66, 73, 74, 76, 77, 85, 90], 9, 8", "0" ], [ "[-62, -20, -26, -24, 92, 66, -74, -4, 18, -82, -36, 92, -4, 92, -80, 56, -24, 4, -48, -10, -14, -46, -16, -58, -58, -6, -68, -22, -82, -16, 76, -30, -86, -38, -66, 28, 58, 30, -44, -56], 24, 28", "4" ], [ "[0, 0...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int a [ ], int n ) { unordered_map < int, int > cnt; int ans = 0, pre_sum = 0; for ( int i = 0; i < n; i ++ ) { ans += ( i * a [ i ] ) - pre_sum; pre_sum += a [ i ]; if ( cnt [ a [ i ] - 1 ] ) ans -= cnt [ a [ i ] - 1 ]; if ( cnt [ a [ i ] + 1 ] ) ans += cnt [ a [ i ] + 1 ]; cnt [ a [ i ] ] ++; } return ans; }
[]
null
[]
MINIMUM_NUMBER_SUBSETS_DISTINCT_ELEMENTS
python
[]
def f_gold ( ar , n ) : res = 0 ar.sort ( ) for i in range ( 0 , n ) : count = 1 for i in range ( n - 1 ) : if ar [ i ] == ar [ i + 1 ] : count += 1 else : break res = max ( res , count ) return res
code_translation
[ [ "[1, 2, 5, 8, 16, 21, 21, 22, 23, 26, 26, 27, 27, 29, 31, 33, 36, 37, 37, 38, 42, 45, 47, 50, 57, 58, 60, 60, 62, 63, 66, 66, 76, 84, 84, 88, 96, 99], 25", "1" ], [ "[-96, -96, -94, -94, -82, -82, -62, -60, -46, -46, -38, -36, -36, -30, -24, -22, -18, -14, -10, 2, 4, 4, 4, 8, 8, 12, 24, 34, 46, 50...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; bool f_gold ( int n ) { if ( n == 0 || n == 9 ) return true; if ( n < 9 ) return false; return f_gold ( ( int ) ( n >> 3 ) - ( int ) ( n & 7 ) ); }
[]
null
[]
ELEMENTS_TO_BE_ADDED_SO_THAT_ALL_ELEMENTS_OF_A_RANGE_ARE_PRESENT_IN_ARRAY_1
python
[]
def f_gold ( arr , n ) : s = dict ( ) count , maxm , minm = 0 , - 10 ** 9 , 10 ** 9 for i in range ( n ) : s [ arr [ i ] ] = 1 if ( arr [ i ] < minm ) : minm = arr [ i ] if ( arr [ i ] > maxm ) : maxm = arr [ i ] for i in range ( minm , maxm + 1 ) : if i not in s.keys ( ) : count += 1 return count
code_translation
[ [ "[1, 4, 5, 5, 11, 11, 12, 14, 16, 20, 23, 23, 25, 27, 29, 33, 33, 35, 37, 39, 39, 44, 44, 45, 47, 51, 51, 53, 55, 65, 73, 73, 75, 78, 79, 79, 80, 82, 86, 86, 87, 87, 88, 90, 91, 91, 94], 26", "31" ], [ "[-38, 20, -94, -68, -96, 36, 48, 32, 44, -56, 72, -28, -6, 22, -54, -46, 58, -60, -80, 28, -34,...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; string f_gold ( string s ) { int n = s . length ( ); int sub_count = n * ( n + 1 ) / 2; string arr [ sub_count ]; int index = 0; for ( int i = 0; i < n; i ++ ) for ( int len = 1; len <= n - i; len ++ ) arr [ index ++ ] = s . substr ( i, len ); sort ( arr, arr + sub_count ); string res = ""; for ( int i = 0; i < sub_count; i ++ ) res += arr [ i ]; return res; }
[]
null
[]
FIND_PERIMETER_CYLINDER
python
[]
def f_gold ( diameter , height ) : return 2 * ( diameter + height )
code_translation
[ [ "70, 78", "296" ], [ "97, 46", "286" ], [ "49, 26", "150" ], [ "56, 61", "234" ], [ "87, 79", "332" ], [ "64, 21", "170" ], [ "75, 93", "336" ], [ "90, 16", "212" ], [ "55, 16", "142" ], [ "73, 29", ...
transcoder-geeksforgeeks
cpp
f_gold
null
[ "import sys" ]
null
[]
REMOVE_MINIMUM_ELEMENTS_EITHER_SIDE_2MIN_MAX
python
[]
import sys def f_gold ( arr , n ) : longest_start = - 1 ; longest_end = 0 ; for start in range ( n ) : min = sys.maxsize ; max = - sys.maxsize ; for end in range ( start , n ) : val = arr [ end ] ; if ( val < min ) : min = val ; if ( val > max ) : max = val ; if ( 2 * min <= max ) : break ; if ( end - start > longest_end - longest_start or longest_start == - 1 ) : longest_start = start ; longest_end = end ; if ( longest_start == - 1 ) : return n ; return ( n - ( longest_end - longest_start + 1 ) ) ;
code_translation
[ [ "[32, 50, 66, 73, 76, 87], 5", "1" ], [ "[68, 74, 16, 40, 6, -44, -36, 94, 6, -24, -4, -58, -16, 24], 11", "9" ], [ "[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 11", "9" ], [ "[91, 22], 1", "0" ], [ "[-84, -80, -78, -76, -58, -54, -52, -48, ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( string s ) { int aCount = 0; int bCount = 0; int cCount = 0; for ( unsigned int i = 0; i < s . size ( ); i ++ ) { if ( s [ i ] == 'a' ) aCount = ( 1 + 2 * aCount ); else if ( s [ i ] == 'b' ) bCount = ( aCount + 2 * bCount ); else if ( s [ i ] == 'c' ) cCount = ( bCount + 2 * cCount ); } return cCount; }
[]
null
[]
COUNT_OFDIFFERENT_WAYS_EXPRESS_N_SUM_1_3_4
python
[]
def f_gold ( n ) : DP = [ 0 for i in range ( 0 , n + 1 ) ] DP [ 0 ] = DP [ 1 ] = DP [ 2 ] = 1 DP [ 3 ] = 2 for i in range ( 4 , n + 1 ) : DP [ i ] = DP [ i - 1 ] + DP [ i - 3 ] + DP [ i - 4 ] return DP [ n ]
code_translation
[ [ "44", "821223649" ], [ "9", "40" ], [ "19", "4895" ], [ "10", "64" ], [ "78", "10472279279564025" ], [ "94", "23112315624967704576" ], [ "70", "222915410843904" ], [ "81", "44361286907595736" ], [ "81", "443612...
transcoder-geeksforgeeks
cpp
f_gold
null
[]
null
[]
SUM_BINOMIAL_COEFFICIENTS
python
[]
def f_gold ( n ) : C = [ [ 0 ] * ( n + 2 ) for i in range ( 0 , n + 2 ) ] 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 ) : sum += C [ n ] [ i ] return sum
code_translation
[ [ "8", "256" ], [ "39", "549755813888" ], [ "25", "33554432" ], [ "44", "17592186044416" ], [ "72", "4722366482869645213696" ], [ "6", "64" ], [ "72", "4722366482869645213696" ], [ "62", "4611686018427387904" ], [ "4...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int arr [ ], int low, int high, int x ) { int mid; if ( x <= arr [ low ] ) return low; if ( x > arr [ high ] ) return - 1; mid = ( low + high ) / 2; if ( arr [ mid ] == x ) return mid; else if ( arr [ mid ] < x ) { if ( mid + 1 <= high && x <= arr [ mid + 1 ] ) return mid + 1; else return f_gold ( arr, mid + 1, high, x ); } else { if ( mid - 1 >= low && x > arr [ mid - 1 ] ) return mid; else return f_gold ( arr, low, mid - 1, x ); } }
[]
null
[]
FIBONACCI_MODULO_P
python
[]
def f_gold ( p ) : first = 1 second = 1 number = 2 next = 1 while ( next ) : next = ( first + second ) % p first = second second = next number = number + 1 return number
code_translation
[ [ "51", "36" ], [ "40", "30" ], [ "68", "18" ], [ "7", "8" ], [ "8", "6" ], [ "32", "24" ], [ "93", "60" ], [ "75", "100" ], [ "71", "70" ], [ "15", "20" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int arr [ ], int n ) { int res = INT_MIN; for ( int i = 0; i < n; i ++ ) { int prefix_sum = arr [ i ]; for ( int j = 0; j < i; j ++ ) prefix_sum += arr [ j ]; int suffix_sum = arr [ i ]; for ( int j = n - 1; j > i; j -- ) suffix_sum += arr [ j ]; if ( prefix_sum == suffix_sum ) res = max ( res, prefix_sum ); } return res; }
[]
null
[]
NTH_EVEN_LENGTH_PALINDROME
python
[]
def f_gold ( n ) : res = n for j in range ( len ( n ) - 1 , - 1 , - 1 ) : res += n [ j ] return res
code_translation
[ [ "'lSUhEvxcgfI'", "'lSUhEvxcgfIIfgcxvEhUSl'" ], [ "'77329283'", "'7732928338292377'" ], [ "'010111111'", "'010111111111111010'" ], [ "'Stazb'", "'StazbbzatS'" ], [ "'0702'", "'07022070'" ], [ "'01111111'", "'0111111111111110'" ], [ "'a'", ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int low, int high ) { int f1 = 0, f2 = 1, f3 = 1; int result = 0; while ( f1 <= high ) { if ( f1 >= low ) result ++; f1 = f2; f2 = f3; f3 = f1 + f2; } return result; }
[]
null
[]
COUNT_TRAILING_ZEROES_FACTORIAL_NUMBER
python
[]
def f_gold ( n ) : count = 0 i = 5 while ( n / i >= 1 ) : count += int ( n / i ) i *= 5 return int ( count )
code_translation
[ [ "9", "1" ], [ "43", "9" ], [ "50", "12" ], [ "32", "7" ], [ "37", "8" ], [ "51", "12" ], [ "33", "7" ], [ "49", "10" ], [ "1", "0" ], [ "75", "18" ] ]
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 ) { if ( curr_sum <= 0 && x > 0 ) { start = end; curr_sum = 0; } 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
[]
NUMBER_OF_PAIRS_IN_AN_ARRAY_HAVING_SUM_EQUAL_TO_PRODUCT
python
[]
def f_gold ( a , n ) : zero = 0 two = 0 for i in range ( n ) : if a [ i ] == 0 : zero += 1 if a [ i ] == 2 : two += 1 cnt = ( zero * ( zero - 1 ) ) // 2 + \ ( two * ( two - 1 ) ) // 2 return cnt
code_translation
[ [ "[9, 10, 20, 26, 26, 28, 31, 34, 35, 36, 36, 37, 39, 43, 44, 44, 46, 49, 54, 57, 58, 63, 64, 64, 65, 67, 70, 70, 74, 75, 77, 78, 79, 81, 82, 83, 84, 86, 95], 31", "0" ], [ "[0, -10, 10, 0, 68, 4, -6, -14, 74, -80, 56, -4, 36, 56, 10, -16, 90, 84, -38, -40, 40, -86, -36, -16, -48, -76, -72, -18, -1...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; bool f_gold ( int arr [ ], int n, int k ) { int count; for ( int i = 0; i < n; i ++ ) { count = 0; for ( int j = 0; j < n; j ++ ) { if ( arr [ j ] == arr [ i ] ) count ++; if ( count > 2 * k ) return false; } } return true; }
[]
null
[]
GIVEN_LARGE_NUMBER_CHECK_SUBSEQUENCE_DIGITS_DIVISIBLE_8
python
[]
def f_gold ( st ) : l = len ( st ) arr = [ 0 ] * l for i in range ( 0 , l ) : for j in range ( i , l ) : for k in range ( j , l ) : if ( arr [ i ] % 8 == 0 ) : return True elif ( ( arr [ i ] * 10 + arr [ j ] ) % 8 == 0 and i != j ) : return True elif ( ( arr [ i ] * 100 + arr [ j ] * 10 + arr [ k ] ) % 8 == 0 and i != j and j != k and i != k ) : return True return False
code_translation
[ [ "'1787075866'", "True" ], [ "'8'", "True" ], [ "'1110101110111'", "True" ], [ "'6673177113'", "True" ], [ "'7'", "True" ], [ "'000001'", "True" ], [ "'dbxMF'", "True" ], [ "'71733'", "True" ], [ "'01101101100'", ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int array [ ], int start, int end ) { if ( start > end ) return end + 1; if ( start != array [ start ] ) return start; int mid = ( start + end ) / 2; if ( array [ mid ] == mid ) return f_gold ( array, mid + 1, end ); return f_gold ( array, start, mid ); }
[]
null
[]
TAIL_RECURSION_FIBONACCI
python
[]
def f_gold ( n , a = 0 , b = 1 ) : if n == 0 : return a if n == 1 : return b return f_gold ( n - 1 , b , a + b ) ;
code_translation
[ [ "4, 43, 24", "158" ], [ "60, 48, 98", "197627515330128" ], [ "92, 21, 69", "618128831345384040090" ], [ "73, 79, 38", "70025457194338790" ], [ "58, 38, 30", "31625143150526" ], [ "82, 26, 12", "1720785110361080648" ], [ "53, 10, 17", ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( unsigned int x, unsigned int p1, unsigned int p2, unsigned int n ) { unsigned int set1 = ( x >> p1 ) & ( ( 1U << n ) - 1 ); unsigned int set2 = ( x >> p2 ) & ( ( 1U << n ) - 1 ); unsigned int Xor = ( set1 ^ set2 ); Xor = ( Xor << p1 ) | ( Xor << p2 ); unsigned int result = x ^ Xor; return result; }
[]
null
[]
DETECT_IF_TWO_INTEGERS_HAVE_OPPOSITE_SIGNS
python
[]
def f_gold ( x , y ) : return ( ( x ^ y ) < 0 ) ;
code_translation
[ [ "59, -99", "True" ], [ "-20, -21", "False" ], [ "-100, 79", "True" ], [ "54, -49", "True" ], [ "-16, 16", "True" ], [ "-23, -68", "False" ], [ "93, 37", "False" ], [ "24, -61", "True" ], [ "-8, 69", "True" ],...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int X [ ], int Y [ ], int m, int n ) { int res = 0; sort ( X, X + m, greater < int > ( ) ); sort ( Y, Y + n, greater < int > ( ) ); int hzntl = 1, vert = 1; int i = 0, j = 0; while ( i < m && j < n ) { if ( X [ i ] > Y [ j ] ) { res += X [ i ] * vert; hzntl ++; i ++; } else { res += Y [ j ] * hzntl; vert ++; j ++; } } int total = 0; while ( i < m ) total += X [ i ++ ]; res += total * vert; total = 0; while ( j < n ) total += Y [ j ++ ]; res += total * hzntl; return res; }
[]
null
[]
COUNT_DISTINCT_NON_NEGATIVE_PAIRS_X_Y_SATISFY_INEQUALITY_XX_YY_N_2_1
python
[]
def f_gold ( n ) : x = 0 res = 0 yCount = 0 while ( yCount * yCount < n ) : yCount = yCount + 1 while ( yCount != 0 ) : res = res + yCount x = x + 1 while ( yCount != 0 and ( x * x + ( yCount - 1 ) * ( yCount - 1 ) >= n ) ) : yCount = yCount - 1 return res
code_translation
[ [ "72", "64" ], [ "75", "69" ], [ "92", "83" ], [ "30", "30" ], [ "45", "41" ], [ "40", "37" ], [ "81", "71" ], [ "17", "17" ], [ "81", "71" ], [ "99", "86" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int x [ ], int y [ ], int n ) { int sum = 0; for ( int i = 0; i < n; i ++ ) for ( int j = i + 1; j < n; j ++ ) sum += ( abs ( x [ i ] - x [ j ] ) + abs ( y [ i ] - y [ j ] ) ); return sum; }
[]
null
[]
MAXIMUM_HEIGHT_OF_TRIANGULAR_ARRANGEMENT_OF_ARRAY_VALUES
python
[]
def f_gold ( a , n ) : result = 1 for i in range ( 1 , n ) : y = ( i * ( i + 1 ) ) / 2 if ( y < n ) : result = i else : break return result
code_translation
[ [ "[8, 10, 11, 14, 14, 17, 20, 20, 22, 22, 22, 23, 25, 30, 33, 39, 39, 41, 43, 45, 46, 46, 46, 50, 51, 53, 57, 59, 60, 64, 64, 66, 72, 72, 75, 77, 85, 85, 87, 88, 90, 91, 93, 94, 94, 95], 38", "8" ], [ "[-44, -90, 20, 4, -56, -50, -80, 74, -82, 20, 62, -26, -10, -14, -76, 82, -88, 92, 30, 44, -62, -...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int n ) { float fibo = 2.078087 * log ( n ) + 1.672276; return round ( fibo ); }
[]
null
[]
COUNT_BINARY_STRINGS_K_TIMES_APPEARING_ADJACENT_TWO_SET_BITS
python
[]
def f_gold ( n , k ) : dp = [ [ [ 0 , 0 ] for __ in range ( k + 1 ) ] for _ in range ( n + 1 ) ] dp [ 1 ] [ 0 ] [ 0 ] = 1 dp [ 1 ] [ 0 ] [ 1 ] = 1 for i in range ( 2 , n + 1 ) : for j in range ( k + 1 ) : dp [ i ] [ j ] [ 0 ] = ( dp [ i - 1 ] [ j ] [ 0 ] + dp [ i - 1 ] [ j ] [ 1 ] ) dp [ i ] [ j ] [ 1 ] = dp [ i - 1 ] [ j ] [ 0 ] if j >= 1 : dp [ i ] [ j ] [ 1 ] += dp [ i - 1 ] [ j - 1 ] [ 1 ] return dp [ n ] [ k ] [ 0 ] + dp [ n ] [ k ] [ 1 ]
code_translation
[ [ "29, 85", "0" ], [ "47, 29", "3615434154" ], [ "77, 96", "0" ], [ "9, 91", "0" ], [ "29, 80", "0" ], [ "94, 85", "4221018" ], [ "51, 87", "0" ], [ "46, 62", "0" ], [ "18, 96", "0" ], [ "86, 86", "0"...
transcoder-geeksforgeeks
cpp
f_gold
null
[]
null
[]
FORM_SMALLEST_NUMBER_USING_ONE_SWAP_OPERATION
python
[]
def f_gold ( num ) : num = list ( num ) n = len ( num ) rightMin = [ 0 ] * n right = 0 rightMin [ n - 1 ] = - 1 ; right = n - 1 ; for i in range ( n - 2 , 0 , - 1 ) : if num [ i ] > num [ right ] : rightMin [ i ] = right else : rightMin [ i ] = - 1 right = i small = - 1 for i in range ( 1 , n ) : if num [ i ] != '0' : if small == - 1 : if num [ i ] < num [ 0 ] : small = i elif num [ i ] < num [ small ] : small = i if small != - 1 : num [ 0 ] , num [ small ] = num [ small ] , num [ 0 ] else : for i in range ( 1 , n ) : if rightMin [ i ] != - 1 : num [ i ] , num [ rightMin [ i ] ] = num [ rightMin [ i ] ] , num [ i ] break return ''.join ( num )
code_translation
[ [ "'ncYltuhSxEfG'", "'EcYltuhSxnfG'" ], [ "'26615541616459'", "'16625541616459'" ], [ "'0101'", "'0011'" ], [ "'hK'", "'Kh'" ], [ "'422162103899'", "'122462103899'" ], [ "'0010'", "'0001'" ], [ "'zfcSh'", "'Sfczh'" ], [ "'92'", ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int arr [ ], int n ) { unordered_set < int > S; int ans = 0; for ( int i = 0; i < n; i ++ ) S . insert ( arr [ i ] ); for ( int i = 0; i < n; i ++ ) { if ( S . find ( arr [ i ] - 1 ) == S . end ( ) ) { int j = arr [ i ]; while ( S . find ( j ) != S . end ( ) ) j ++; ans = max ( ans, j - arr [ i ] ); } } return ans; }
[]
null
[]
COUNT_NUMBER_BINARY_STRINGS_WITHOUT_CONSECUTIVE_1S
python
[]
def f_gold ( n ) : a = [ 0 for i in range ( n ) ] b = [ 0 for i in range ( n ) ] a [ 0 ] = b [ 0 ] = 1 for i in range ( 1 , n ) : a [ i ] = a [ i - 1 ] + b [ i - 1 ] b [ i ] = a [ i - 1 ] return a [ n - 1 ] + b [ n - 1 ]
code_translation
[ [ "86", "1100087778366101931" ], [ "75", "5527939700884757" ], [ "14", "987" ], [ "5", "13" ], [ "41", "433494437" ], [ "35", "24157817" ], [ "30", "2178309" ], [ "89", "4660046610375530309" ], [ "84", "420196140...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; long int f_gold ( int n ) { if ( n == 1 ) return 1; long int z; float e = 2.71; z = sqrt ( 2 * 3.14 * n ) * pow ( ( n / e ), n ); return z; }
[ "import math" ]
null
[]
CHECK_GIVEN_CIRCLE_LIES_COMPLETELY_INSIDE_RING_FORMED_TWO_CONCENTRIC_CIRCLES
python
[]
import math def f_gold ( r , R , r1 , x1 , y1 ) : dis = int ( math.sqrt ( x1 * x1 + y1 * y1 ) ) return ( dis - r1 >= R and dis + r1 <= r )
code_translation
[ [ "8, 4, 2, 6, 0", "True" ], [ "400, 1, 10, 74, 38", "True" ], [ "1, 400, 10, 74, 38", "False" ], [ "61, 40, 2, 50, 0", "True" ], [ "60, 49, 68, 77, 71", "False" ], [ "88, 10, 69, 71, 26", "False" ], [ "60, 79, 92, 29, 38", "False" ],...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int n ) { if ( n < 4 ) return - 1; int rem = n % 4; if ( rem == 0 ) return n / 4; if ( rem == 1 ) { if ( n < 9 ) return - 1; return ( n - 9 ) / 4 + 1; } if ( rem == 2 ) return ( n - 6 ) / 4 + 1; if ( rem == 3 ) { if ( n < 15 ) return - 1; return ( n - 15 ) / 4 + 2; } }
[]
null
[]
COMPUTE_AVERAGE_TWO_NUMBERS_WITHOUT_OVERFLOW_1
python
[]
def f_gold ( a , b ) : return ( a // 2 ) + ( b // 2 ) + ( ( a % 2 + b % 2 ) // 2 )
code_translation
[ [ "9, 81", "45" ], [ "68, 79", "73" ], [ "51, 2", "26" ], [ "31, 49", "40" ], [ "14, 10", "12" ], [ "73, 9", "41" ], [ "51, 13", "32" ], [ "75, 67", "71" ], [ "98, 51", "74" ], [ "83, 74", "78" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( char s [ ], char t [ ] ) { int count = 0; for ( int i = 0; i < strlen ( t ); i ++ ) { if ( count == strlen ( s ) ) break; if ( t [ i ] == s [ count ] ) count ++; } return count; }
[]
null
[]
PROGRAM_AREA_SQUARE
python
[]
def f_gold ( side ) : area = side * side return area
code_translation
[ [ "50", "2500" ], [ "64", "4096" ], [ "92", "8464" ], [ "23", "529" ], [ "38", "1444" ], [ "55", "3025" ], [ "67", "4489" ], [ "56", "3136" ], [ "60", "3600" ], [ "90", "8100" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int A [ ], int B [ ], int m, int n ) { sort ( A, A + m ); sort ( B, B + n ); int a = 0, b = 0; int result = INT_MAX; while ( a < m && b < n ) { if ( abs ( A [ a ] - B [ b ] ) < result ) result = abs ( A [ a ] - B [ b ] ); if ( A [ a ] < B [ b ] ) a ++; else b ++; } return result; }
[]
null
[]
MAXIMUM_SUM_PAIRS_SPECIFIC_DIFFERENCE
python
[]
def f_gold ( arr , N , K ) : arr.sort ( ) dp = [ 0 ] * N dp [ 0 ] = 0 for i in range ( 1 , N ) : dp [ i ] = dp [ i - 1 ] if ( arr [ i ] - arr [ i - 1 ] < K ) : if ( i >= 2 ) : dp [ i ] = max ( dp [ i ] , dp [ i - 2 ] + arr [ i ] + arr [ i - 1 ] ) ; else : dp [ i ] = max ( dp [ i ] , arr [ i ] + arr [ i - 1 ] ) ; return dp [ N - 1 ]
code_translation
[ [ "[48, 53, 67, 78, 78, 93, 95], 6, 4", "156" ], [ "[-70, -32, -2, 18, 30, 32, 52, 70, 72, 88], 8, 8", "62" ], [ "[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, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 37, 31", "10" ], [ "[2, 3, 5, 5, 6, 10, ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; bool f_gold ( int n ) { return ( ! ( n & 1 ) ); }
[ "import math" ]
null
[]
AREA_OF_THE_CIRCLE_THAT_HAS_A_SQUARE_AND_A_CIRCLE_INSCRIBED_IN_IT
python
[]
import math def f_gold ( a ) : area = ( math.pi * a * a ) / 4 return area
code_translation
[ [ "77", "4656.625710783471" ], [ "18", "254.46900494077323" ], [ "83", "5410.607947645021" ], [ "39", "1194.5906065275187" ], [ "68", "3631.6811075498013" ], [ "28", "615.7521601035994" ], [ "71", "3959.192141686537" ], [ "14", ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int a [ ], int b [ ], int n ) { sort ( a, a + n ); sort ( b, b + n ); int result = 0; for ( int i = 0; i < n; ++ i ) { result = result + abs ( a [ i ] - b [ i ] ); } return result; }
[]
null
[]
MULTIPLY_AN_INTEGER_WITH_3_5
python
[]
def f_gold ( x ) : return ( x << 1 ) + x + ( x >> 1 )
code_translation
[ [ "58", "203" ], [ "16", "56" ], [ "82", "287" ], [ "33", "115" ], [ "88", "308" ], [ "51", "178" ], [ "81", "283" ], [ "38", "133" ], [ "79", "276" ], [ "89", "311" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int num, int divisor ) { while ( num >= divisor ) num -= divisor; return num; }
[]
null
[]
MAXIMUM_SUM_SUBSEQUENCE_LEAST_K_DISTANT_ELEMENTS
python
[]
def f_gold ( arr , N , k ) : MS = [ 0 for i in range ( N ) ] MS [ N - 1 ] = arr [ N - 1 ] for i in range ( N - 2 , - 1 , - 1 ) : if ( i + k + 1 >= N ) : MS [ i ] = max ( arr [ i ] , MS [ i + 1 ] ) else : MS [ i ] = max ( arr [ i ] + MS [ i + k + 1 ] , MS [ i + 1 ] ) return MS [ 0 ]
code_translation
[ [ "[3, 5, 20, 21, 23, 26, 27, 31, 33, 38, 39, 41, 48, 48, 50, 51, 56, 57, 64, 68, 69, 70, 71, 74, 76, 86, 97], 23, 15", "98" ], [ "[32, 34, -40, 90, -82, -70, 30, 26, -76, -46, -84, 76, -76], 9, 10", "90" ], [ "[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...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int arr [ ], int n ) { sort ( arr, arr + n ); return arr [ n - 1 ] + arr [ n - 2 ] + arr [ n - 3 ]; }
[ "import sys" ]
null
[]
DYNAMIC_PROGRAMMING_SET_28_MINIMUM_INSERTIONS_TO_FORM_A_PALINDROME
python
[]
import sys def f_gold ( str , l , h ) : if ( l > h ) : return sys.maxsize if ( l == h ) : return 0 if ( l == h - 1 ) : return 0 if ( str [ l ] == str [ h ] ) else 1 if ( str [ l ] == str [ h ] ) : return f_gold ( str , l + 1 , h - 1 ) else : return ( min ( f_gold ( str , l , h - 1 ) , f_gold ( str , l + 1 , h ) ) + 1 )
code_translation
[ [ "['F', 'F', 'J', 'K', 'K', 'L', 'P', 'S', 'T', 'V', 'W', 'Y', 'b', 'd', 'j', 'l', 't', 'u', 'x', 'y'], 11, 11", "0" ], [ "['0', '1', '8', '8', '8', '4', '4', '3', '9', '6', '5', '2', '8', '2', '0', '2', '6', '0', '7', '7', '3', '2', '4', '5', '9', '7', '2', '4', '1', '8', '7', '9', '8', '0', '8', ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int arr [ ], int n ) { int ans = 0; for ( int i = 0; i < n; i ++ ) for ( int j = i + 1; j < n; j ++ ) if ( arr [ i ] == arr [ j ] ) ans ++; return ans; }
[]
null
[]
SUM_SERIES_555555_N_TERMS
python
[]
def f_gold ( n ) : return ( int ) ( 0.6172 * ( pow ( 10 , n ) - 1 ) - 0.55 * n )
code_translation
[ [ "18", "617200000000000000" ], [ "81", "617199999999999917125494104322701119480482791516235510304887841509964568007278592" ], [ "77", "61720000000000002223209770321473706212913932736699901607714125885487833939968" ], [ "84", "617199999999999978627872438760098151064610958...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int n, int m, int k ) { if ( m <= n - k + 1 ) return m + k - 1; m = m - ( n - k + 1 ); return ( m % n == 0 ) ? n : ( m % n ); }
[]
null
[]
SUM_SUBSETS_SET_FORMED_FIRST_N_NATURAL_NUMBERS
python
[]
def f_gold ( n ) : return ( n * ( n + 1 ) / 2 ) * ( 1 << ( n - 1 ) )
code_translation
[ [ "76", "1.1054115463101266e+26" ], [ "26", "11777605632.0" ], [ "45", "1.820791255597056e+16" ], [ "35", "10823317585920.0" ], [ "34", "5111011082240.0" ], [ "22", "530579456.0" ], [ "3", "24.0" ], [ "25", "5452595200.0" ...
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
[]
PROGRAM_TO_FIND_REMAINDER_WITHOUT_USING_MODULO_OR_OPERATOR_1
python
[]
def f_gold ( num , divisor ) : if ( divisor == 0 ) : return False if ( divisor < 0 ) : divisor = - divisor if ( num < 0 ) : num = - num i = 1 product = 0 while ( product <= num ) : product = divisor * i i += 1 return num - ( product - divisor )
code_translation
[ [ "34, 55", "34" ], [ "63, 22", "19" ], [ "15, 26", "15" ], [ "56, 58", "56" ], [ "63, 94", "63" ], [ "28, 45", "28" ], [ "54, 97", "54" ], [ "2, 58", "2" ], [ "94, 91", "3" ], [ "82, 40", "2" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; unsigned int f_gold ( unsigned int n, unsigned int d ) { return ( n & ( d - 1 ) ); }
[]
null
[]
COMPOSITE_NUMBER
python
[]
def f_gold ( n ) : if ( n <= 1 ) : return False if ( n <= 3 ) : return False if ( n % 2 == 0 or n % 3 == 0 ) : return True i = 5 while ( i * i <= n ) : if ( n % i == 0 or n % ( i + 2 ) == 0 ) : return True i = i + 6 return False
code_translation
[ [ "62", "True" ], [ "13", "False" ], [ "29", "False" ], [ "72", "True" ], [ "30", "True" ], [ "20", "True" ], [ "10", "True" ], [ "47", "False" ], [ "91", "True" ], [ "52", "True" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int a, int b, int c ) { int x = a - b; int y = b - c; int z = a - c; if ( x * y > 0 ) return b; else if ( x * z > 0 ) return c; else return a; }
[ "from queue import Queue" ]
null
[]
PROGRAM_PAGE_REPLACEMENT_ALGORITHMS_SET_2_FIFO
python
[]
from queue import Queue def f_gold ( pages , n , capacity ) : s = set ( ) indexes = Queue ( ) page_faults = 0 for i in range ( n ) : if ( len ( s ) < capacity ) : if ( pages [ i ] not in s ) : s.add ( pages [ i ] ) page_faults += 1 indexes.put ( pages [ i ] ) else : if ( pages [ i ] not in s ) : val = indexes.queue [ 0 ] indexes.get ( ) s.remove ( val ) s.add ( pages [ i ] ) indexes.put ( pages [ i ] ) page_faults += 1 return page_faults
code_translation
[ [ "[4, 4, 6, 7, 8, 11, 13, 18, 26, 35, 36, 37, 45, 46, 46, 47, 48, 49, 51, 52, 53, 56, 61, 74, 75, 77, 80, 83, 85, 86, 87, 90, 93, 95, 97, 98, 99, 99], 36, 37", "34" ], [ "[78, -48, 50, -20, -6, 58, -8, 66, 72, 68, 4, 80, 58, -26, -82, -56, 92, 76, 20, 82, -46, 86, 38, 60, -62, -48, 76, 8, -66, -4, ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int arr [ ], int N ) { int lis [ N ]; 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 ] && lis [ i ] < lis [ j ] + 1 ) lis [ i ] = lis [ j ] + 1; int max = 0; for ( int i = 0; i < N; i ++ ) if ( max < lis [ i ] ) max = lis [ i ]; return ( N - max ); }
[]
null
[]
MAXIMUM_TRIPLET_SUM_ARRAY_2
python
[]
def f_gold ( arr , n ) : maxA = - 100000000 maxB = - 100000000 maxC = - 100000000 for i in range ( 0 , n ) : if ( arr [ i ] > maxA ) : maxC = maxB maxB = maxA maxA = arr [ i ] elif ( arr [ i ] > maxB ) : maxC = maxB maxB = arr [ i ] elif ( arr [ i ] > maxC ) : maxC = arr [ i ] return ( maxA + maxB + maxC )
code_translation
[ [ "[4, 7, 12, 21, 22, 25, 27, 28, 28, 31, 32, 32, 41, 45, 47, 51, 53, 60, 61, 61, 63, 71, 74, 82, 83, 85, 88, 92, 96, 96], 28", "265" ], [ "[-52, 26, 74, -62, -76], 2", "-100000026" ], [ "[0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 11", "3" ], [ "[63, 71, 15, 28, 31, 84, 8...
transcoder-geeksforgeeks
cpp
f_gold
null
[ "import math" ]
null
[]
PROGRAM_CALCULATE_AREA_OCTAGON
python
[]
import math def f_gold ( side ) : return ( 2 * ( 1 + ( math.sqrt ( 2 ) ) ) * side * side )
code_translation
[ [ "5859.798616323926", "165794860.15449765" ], [ "-6381.210375893524", "196612808.27272156" ], [ "2442.246292006922", "28799476.852711495" ], [ "-9624.81536339737", "447291345.3087225" ], [ "8679.436805247444", "363738081.5089271" ], [ "-2682.324540108...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int arr1 [ ], int arr2 [ ], int n ) { for ( int i = 0; i < n; i ++ ) if ( arr1 [ i ] != arr2 [ i ] ) return i; return n; }
[ "import math" ]
null
[]
PROGRAM_CALCULATE_VOLUME_OCTAHEDRON
python
[]
import math def f_gold ( side ) : return ( ( side * side * side ) * ( math.sqrt ( 2 ) / 3 ) )
code_translation
[ [ "3355.322051344013", "17807230335.375374" ], [ "-891.0551553192736", "-333508958.9649689" ], [ "8242.699647177868", "263998930936.71603" ], [ "-9259.146104439229", "-374202387762.81836" ], [ "7712.806145993083", "216287285897.3415" ], [ "-4998.858862...
transcoder-geeksforgeeks
cpp
f_gold
null
[]
null
[]
SEARCH_INSERT_AND_DELETE_IN_A_SORTED_ARRAY
python
[]
def f_gold ( arr , low , high , key ) : if ( high < low ) : return - 1 mid = ( low + high ) / 2 if ( key == arr [ int ( mid ) ] ) : return mid if ( key > arr [ int ( mid ) ] ) : return f_gold ( arr , ( mid + 1 ) , high , key ) return ( f_gold ( arr , low , ( mid - 1 ) , key ) )
code_translation
[ [ "[2, 10, 73, 91, 98], 2, 4, 4", "-1" ], [ "[30, 24, 24, -8, 64, 50, 46, -76, 26, 8, -92, -78, 40, -86, 96, 14, 60, 38, 6, -72, -6, -20, 26, -26, 0, 2], 20, 13, 21", "-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, 1, 1, 1, 1], 30, 27, 29",...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int arr [ ], int n ) { int res = 0; for ( int i = 0; i < n - 1; i ++ ) res = res ^ ( i + 1 ) ^ arr [ i ]; res = res ^ arr [ n - 1 ]; return res; }
[]
null
[]
MAXIMUM_NUMBER_SEGMENTS_LENGTHS_B_C
python
[]
def f_gold ( n , a , b , c ) : dp = [ - 1 ] * ( n + 10 ) dp [ 0 ] = 0 for i in range ( 0 , n ) : if ( dp [ i ] != - 1 ) : if ( i + a <= n ) : dp [ i + a ] = max ( dp [ i ] + 1 , dp [ i + a ] ) if ( i + b <= n ) : dp [ i + b ] = max ( dp [ i ] + 1 , dp [ i + b ] ) if ( i + c <= n ) : dp [ i + c ] = max ( dp [ i ] + 1 , dp [ i + c ] ) return dp [ n ]
code_translation
[ [ "23, 16, 23, 18", "1" ], [ "62, 76, 81, 97", "-1" ], [ "32, 46, 1, 78", "32" ], [ "82, 48, 72, 58", "-1" ], [ "94, 99, 62, 38", "-1" ], [ "44, 21, 46, 60", "-1" ], [ "4, 57, 2, 77", "2" ], [ "53, 23, 80, 5", "7" ], [ ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; string f_gold ( int n ) { if ( n == 0 ) return "0"; string bin = ""; while ( n > 0 ) { bin = ( ( n & 1 ) == 0 ? '0' : '1' ) + bin; n >>= 1; } return bin; }
[]
null
[]
COUNT_NUMBER_OF_WAYS_TO_COVER_A_DISTANCE_1
python
[]
def f_gold ( dist ) : count = [ 0 ] * ( dist + 1 ) count [ 0 ] = 1 count [ 1 ] = 1 count [ 2 ] = 2 for i in range ( 3 , dist + 1 ) : count [ i ] = ( count [ i - 1 ] + count [ i - 2 ] + count [ i - 3 ] ) return count [ dist ] ;
code_translation
[ [ "37", "3831006429" ], [ "82", "3108406708580377597810" ], [ "87", "65431225571591367370292" ], [ "80", "918838005896863447985" ], [ "92", "1377311813149359327046015" ], [ "58", "1383410902447554" ], [ "98", "53324762928098149064722658...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; bool f_gold ( string str ) { int zeros = 0, ones = 0; for ( char ch : str ) ( ch == '0' ) ? ++ zeros : ++ ones; return ( zeros == 1 || ones == 1 ); }
[]
null
[]
MIDDLE_OF_THREE_USING_MINIMUM_COMPARISONS_1
python
[]
def f_gold ( a , b , c ) : if a > b : if ( b > c ) : return b elif ( a > c ) : return c else : return a else : if ( a > c ) : return a elif ( b > c ) : return c else : return b
code_translation
[ [ "43, 24, 7", "24" ], [ "76, 54, 66", "66" ], [ "57, 5, 40", "40" ], [ "10, 13, 4", "10" ], [ "59, 47, 56", "56" ], [ "92, 14, 50", "50" ], [ "49, 62, 65", "62" ], [ "16, 95, 12", "16" ], [ "33, 41, 90", "41" ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int n ) { int position = 1; int m = 1; while ( ! ( n & m ) ) { m = m << 1; position ++; } return position; }
[]
null
[]
MINIMUM_STEPS_TO_DELETE_A_STRING_AFTER_REPEATED_DELETION_OF_PALINDROME_SUBSTRINGS
python
[]
def f_gold(str): N = len(str) dp = [[0 for x in range(N + 1)] for y in range(N + 1)] for l in range(1, N + 1): i = 0 j = l - 1 while j < N: if (l == 1): dp[i][j] = 1 else: dp[i][j] = 1 + dp[i + 1][j] if (str[i] == str[i + 1]): dp[i][j] = min(1 + dp[i + 2][j], dp[i][j]) for K in range(i + 2, j + 1): if (str[i] == str[K]): dp[i][j] = min(dp[i + 1][K - 1] + dp[K + 1][j], dp[i][j]) i += 1 j += 1 return dp[0][N - 1]
code_translation
[ [ "'YCtLQtHLwr'", "8" ], [ "'47713514383248'", "7" ], [ "'0100101001111'", "3" ], [ "'XfdIYVn'", "7" ], [ "'45499225407'", "5" ], [ "'000100111001'", "2" ], [ "'ZoUQhQwoap'", "6" ], [ "'18579027952'", "7" ], [ "'0000...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; bool f_gold ( string str ) { int n = str . length ( ); if ( n == 0 ) return false; if ( n == 1 ) return ( ( str [ 0 ] - '0' ) % 4 == 0 ); int last = str [ n - 1 ] - '0'; int second_last = str [ n - 2 ] - '0'; return ( ( second_last * 10 + last ) % 4 == 0 ); }
[]
null
[]
DYNAMIC_PROGRAMMING_HIGH_EFFORT_VS_LOW_EFFORT_TASKS_PROBLEM
python
[]
def f_gold ( high , low , n ) : if ( n <= 0 ) : return 0 return max ( high [ n - 1 ] + f_gold ( high , low , ( n - 2 ) ) , low [ n - 1 ] + f_gold ( high , low , ( n - 1 ) ) ) ;
code_translation
[ [ "[1, 3, 9, 10, 13, 14, 15, 15, 17, 22, 23, 28, 30, 31, 37, 42, 45, 62, 62, 68, 68, 68, 78, 79, 82, 84, 87, 90, 99], [5, 10, 11, 14, 16, 22, 24, 30, 34, 35, 37, 37, 39, 41, 42, 42, 43, 55, 57, 63, 71, 76, 83, 83, 85, 90, 91, 97, 99], 18", "537" ], [ "[-78, -12, 26, 80, 50, 4, -80, 86, 12, -2, 18, -...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( string str ) { int n = str . length ( ); return n * ( n + 1 ) / 2; }
[]
null
[]
FIND_SUM_MODULO_K_FIRST_N_NATURAL_NUMBER_1
python
[]
def f_gold ( N , K ) : ans = 0 ; y = N / K ; x = N % K ; ans = ( ( K * ( K - 1 ) / 2 ) * y + ( x * ( x + 1 ) ) / 2 ) ; return int ( ans ) ;
code_translation
[ [ "40, 90", "2600" ], [ "46, 64", "2530" ], [ "97, 20", "1074" ], [ "63, 1", "0" ], [ "92, 52", "3166" ], [ "60, 35", "1345" ], [ "67, 40", "1684" ], [ "61, 62", "3751" ], [ "74, 61", "2311" ], [ "67, 41"...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int arr [ ], int n ) { int leftMax [ n ]; leftMax [ 0 ] = INT_MIN; for ( int i = 1; i < n; i ++ ) leftMax [ i ] = max ( leftMax [ i - 1 ], arr [ i - 1 ] ); int rightMin = INT_MAX; for ( int i = n - 1; i >= 0; i -- ) { if ( leftMax [ i ] < arr [ i ] && rightMin > arr [ i ] ) return i; rightMin = min ( rightMin, arr [ i ] ); } return - 1; }
[ "import math" ]
null
[]
MINIMUM_PERIMETER_N_BLOCKS
python
[]
import math def f_gold ( n ) : l = math.sqrt ( n ) sq = l * l if ( sq == n ) : return l * 4 else : row = n / l perimeter = 2 * ( l + row ) if ( n % l != 0 ) : perimeter += 2 return perimeter
code_translation
[ [ "45", "28.832815729997478" ], [ "80", "37.77708763999664" ], [ "54", "29.393876913398138" ], [ "48", "29.712812921102035" ], [ "83", "36.4417343165772" ], [ "68", "32.984845004941285" ], [ "32", "24.62741699796952" ], [ "20", ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int n ) { int sum = 0; while ( n > 0 ) { sum += ( n % 10 ); n /= 10; } if ( sum == 1 ) return 10; return sum; }
[]
null
[]
TURN_OFF_THE_RIGHTMOST_SET_BIT
python
[]
def f_gold ( n ) : return n & ( n - 1 )
code_translation
[ [ "9", "8" ], [ "54", "52" ], [ "60", "56" ], [ "32", "0" ], [ "41", "40" ], [ "64", "0" ], [ "4", "0" ], [ "51", "50" ], [ "57", "56" ], [ "92", "88" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int n, int m ) { int dp [ n + 1 ] [ m + 1 ]; memset ( dp, 0, sizeof ( dp ) ); for ( int i = 1; i <= n; i ++ ) { for ( int j = 0; j <= m; j ++ ) { if ( i > j ) { if ( j == 0 ) dp [ i ] [ j ] = 1; else dp [ i ] [ j ] = ( ( i - j ) * dp [ i - 1 ] [ j - 1 ] ) + ( ( j + 1 ) * dp [ i - 1 ] [ j ] ); } } } return dp [ n ] [ m ]; }
[]
null
[]
FIND_REPEATED_CHARACTER_PRESENT_FIRST_STRING
python
[]
def f_gold ( s ) : p = - 1 for i in range ( len ( s ) ) : for j in range ( i + 1 , len ( s ) ) : if ( s [ i ] == s [ j ] ) : p = i break if ( p != - 1 ) : break return p
code_translation
[ [ "'ORXMflacQFBv'", "-1" ], [ "'39977638567848'", "0" ], [ "'011110011011'", "0" ], [ "'fYjfNy'", "0" ], [ "'222280492'", "0" ], [ "'11'", "0" ], [ "'UjntBg'", "-1" ], [ "'6866190138212'", "0" ], [ "'0000'", "0" ...
transcoder-geeksforgeeks
cpp
f_gold
null
[]
null
[]
FIND_THE_MAXIMUM_SUBARRAY_XOR_IN_A_GIVEN_ARRAY
python
[]
def f_gold ( arr , n ) : ans = - 2147483648 for i in range ( n ) : curr_xor = 0 for j in range ( i , n ) : curr_xor = curr_xor ^ arr [ j ] ans = max ( ans , curr_xor ) return ans
code_translation
[ [ "[1, 7, 7, 11, 12, 18, 20, 23, 27, 30, 44, 47, 53, 53, 55, 57, 57, 58, 61, 62, 67, 74, 76, 80, 86, 86], 13", "63" ], [ "[-34, -4, 68, -82, 54, 20, 6, -18, -70, 98, -40, 80, -28, 78, 28, 56, 26, 2, 2, -56, -66, 44, 0, -72, 12, 54, -40, 18, 28, -48, -56, 72, 84, 60, 76, 26, -8, 62], 21", "126" ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int ar [ ], int n ) { int res = 0; sort ( ar, ar + n ); for ( int i = 0; i < n; i ++ ) { int count = 1; for (; i < n - 1; i ++ ) { if ( ar [ i ] == ar [ i + 1 ] ) count ++; else break; } res = max ( res, count ); } return res; }
[]
null
[]
STRING_CONTAINING_FIRST_LETTER_EVERY_WORD_GIVEN_STRING_SPACES
python
[]
def f_gold ( str ) : result = "" v = True for i in range ( len ( str ) ) : if ( str [ i ] == ' ' ) : v = True elif ( str [ i ] != ' ' and v == True ) : result += ( str [ i ] ) v = False return result
code_translation
[ [ "'t a'", "'ta'" ], [ "'77 78 2 600 7'", "'77267'" ], [ "'011 10 10'", "'011'" ], [ "'kV Co O iR'", "'kCOi'" ], [ "'2'", "'2'" ], [ "'0 11'", "'01'" ], [ "'Y sT wgheC'", "'Ysw'" ], [ "'58 824 6'", "'586'" ], [ "'00 ...
transcoder-geeksforgeeks
cpp
f_gold
null
[]
null
[]
MAXIMUM_POSSIBLE_DIFFERENCE_TWO_SUBSETS_ARRAY
python
[]
def f_gold ( arr , n ) : SubsetSum_1 = 0 SubsetSum_2 = 0 for i in range ( 0 , n ) : isSingleOccurance = True for j in range ( i + 1 , n ) : if ( arr [ i ] == arr [ j ] ) : isSingleOccurance = False arr [ i ] = arr [ j ] = 0 break if ( isSingleOccurance == True ) : if ( arr [ i ] > 0 ) : SubsetSum_1 += arr [ i ] else : SubsetSum_2 += arr [ i ] return abs ( SubsetSum_1 - SubsetSum_2 )
code_translation
[ [ "[5, 14, 15, 21, 0, 0, 42, 0, 0, 0, 0, 48, 0, 0, 53, 60, 62, 69, 69, 79, 82, 86, 96], 15", "198" ], [ "[-54, 0, -22, 94, 58, 0, -12, 84, 0, 0, -34, 16, -10, -32, 50, -78, 68, -52, -64, 66, 0, 0, -38, -18, -84, -66, -36, 64, -12, 44, 48, 8, 42], 28", "1100" ], [ "[0, 0, 0, 1], 2", "...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int diameter, int height ) { return 2 * ( diameter + height ); }
[]
null
[]
RECURSIVELY_BREAK_NUMBER_3_PARTS_GET_MAXIMUM_SUM_1
python
[]
def f_gold ( n ) : dp = [ 0 ] * ( n + 1 ) dp [ 0 ] = 0 dp [ 1 ] = 1 for i in range ( 2 , n + 1 ) : dp [ i ] = max ( dp [ int ( i / 2 ) ] + dp [ int ( i / 3 ) ] + dp [ int ( i / 4 ) ] , i ) ; return dp [ n ]
code_translation
[ [ "50", "57" ], [ "83", "93" ], [ "18", "19" ], [ "24", "27" ], [ "31", "32" ], [ "38", "41" ], [ "94", "104" ], [ "24", "27" ], [ "13", "13" ], [ "53", "57" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int arr [ ], int n ) { int longest_start = - 1, longest_end = 0; for ( int start = 0; start < n; start ++ ) { int min = INT_MAX, max = INT_MIN; for ( int end = start; end < n; end ++ ) { int val = arr [ end ]; if ( val < min ) min = val; if ( val > max ) max = val; if ( 2 * min <= max ) break; if ( end - start > longest_end - longest_start || longest_start == - 1 ) { longest_start = start; longest_end = end; } } } if ( longest_start == - 1 ) return n; return ( n - ( longest_end - longest_start + 1 ) ); }
[ "import math" ]
null
[]
MINIMUM_COST_FOR_ACQUIRING_ALL_COINS_WITH_K_EXTRA_COINS_ALLOWED_WITH_EVERY_COIN
python
[]
import math def f_gold ( coin , n , k ) : coin.sort ( ) coins_needed = math.ceil ( 1.0 * n // ( k + 1 ) ) ; ans = 0 for i in range ( coins_needed - 1 + 1 ) : ans += coin [ i ] return ans
code_translation
[ [ "[2, 4, 5, 9, 10, 10, 11, 14, 15, 19, 21, 22, 29, 36, 36, 38, 39, 39, 39, 41, 41, 42, 45, 45, 48, 55, 56, 57, 64, 66, 66, 66, 66, 69, 74, 76, 80, 81, 82, 82, 85, 87, 95, 95], 33, 27", "2" ], [ "[-98, -88, -52, -10, -6, 16, 20, 36, 48, 66, 68, 94], 6, 10", "0" ], [ "[0, 0, 0, 0, 0, 0, 0...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int n ) { int DP [ n + 1 ]; DP [ 0 ] = DP [ 1 ] = DP [ 2 ] = 1; DP [ 3 ] = 2; for ( int i = 4; i <= n; i ++ ) DP [ i ] = DP [ i - 1 ] + DP [ i - 3 ] + DP [ i - 4 ]; return DP [ n ]; }
[]
null
[]
PADOVAN_SEQUENCE
python
[]
def f_gold ( n ) : pPrevPrev , pPrev , pCurr , pNext = 1 , 1 , 1 , 1 for i in range ( 3 , n + 1 ) : pNext = pPrevPrev + pPrev pPrevPrev = pPrev pPrev = pCurr pCurr = pNext return pNext ;
code_translation
[ [ "1", "1" ], [ "92", "124155792775" ], [ "29", "2513" ], [ "52", "1618192" ], [ "55", "3761840" ], [ "13", "28" ], [ "83", "9882257736" ], [ "83", "9882257736" ], [ "10", "12" ], [ "67", "109870576" ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int n ) { int C [ n + 1 ] [ n + 1 ]; for ( int i = 0; i <= n; i ++ ) { for ( int 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 ++ ) sum += C [ n ] [ i ]; return sum; }
[]
null
[]
CEILING_IN_A_SORTED_ARRAY
python
[]
def f_gold ( arr , low , high , x ) : if x <= arr [ low ] : return low i = low for i in range ( high ) : if arr [ i ] == x : return i if arr [ i ] < x and arr [ i + 1 ] >= x : return i + 1 return - 1
code_translation
[ [ "[2, 3, 4, 6, 8, 9, 9, 10, 11, 16, 19, 20, 21, 21, 21, 24, 24, 25, 28, 30, 30, 30, 32, 34, 35, 39, 41, 42, 49, 52, 57, 59, 61, 62, 66, 68, 71, 73, 76, 79, 83, 84, 85, 86, 87, 87], 23, 37, 44", "28" ], [ "[92, 50, -84, 60, 32, -54, 84, -82, -42, -72, -64, -28, -48, 66, 92, -42, 42, -66, 52, -30, 48...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int p ) { int first = 1, second = 1, number = 2, next = 1; while ( next ) { next = ( first + second ) % p; first = second; second = next; number ++; } return number; }
[]
null
[]
MINIMUM_SUM_SUBSEQUENCE_LEAST_ONE_EVERY_FOUR_CONSECUTIVE_ELEMENTS_PICKED_1
python
[]
def f_gold ( ar , n ) : if ( n <= 4 ) : return min ( ar ) sum = [ 0 for i in range ( n ) ] sum [ 0 ] = ar [ 0 ] sum [ 1 ] = ar [ 1 ] sum [ 2 ] = ar [ 2 ] sum [ 3 ] = ar [ 3 ] for i in range ( 4 , n ) : sum [ i ] = ar [ i ] + min ( sum [ i - 4 : i ] ) return min ( sum [ n - 4 : n ] )
code_translation
[ [ "[4, 4, 9, 26, 31, 31, 33, 35, 40, 45, 48, 52, 57, 60, 69, 75, 82, 89, 90, 92, 95, 97], 19", "188" ], [ "[60, -68, 30, -62, -8, 48, -20, 30, 16, -60, -20], 5", "-76" ], [ "[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, 1, 1, 1, 1,...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; string f_gold ( string n ) { string res = n; for ( int j = n . length ( ) - 1; j >= 0; -- j ) res += n [ j ]; return res; }
[]
null
[]
COUNT_PAIRS_TWO_SORTED_ARRAYS_WHOSE_SUM_EQUAL_GIVEN_VALUE_X
python
[]
def f_gold ( arr1 , arr2 , m , n , x ) : count = 0 for i in range ( m ) : for j in range ( n ) : if arr1 [ i ] + arr2 [ j ] == x : count = count + 1 return count
code_translation
[ [ "[11, 13, 16, 23, 26, 28, 31, 34, 37, 39, 44, 48, 56, 59, 79, 91, 96, 98], [1, 1, 9, 14, 17, 23, 26, 31, 33, 36, 53, 60, 71, 75, 76, 84, 87, 88], 9, 15, 11", "0" ], [ "[50, 14, -98, 14, 90, 36, 66, 44, 10, -98, -24, -36, -32, -50], [34, -6, -66, 0, -6, 82, 60, -98, -8, 60, -2, 4, 22, 76], 11, 12, ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int n ) { int count = 0; for ( int i = 5; n / i >= 1; i *= 5 ) count += n / i; return count; }
[]
null
[]
CHECK_IF_A_NUMBER_IS_JUMBLED_OR_NOT
python
[]
def f_gold ( num ) : if ( num // 10 == 0 ) : return True while ( num != 0 ) : if ( num // 10 == 0 ) : return True digit1 = num % 10 digit2 = ( num // 10 ) % 10 if ( abs ( digit2 - digit1 ) > 1 ) : return False num = num // 10 return True
code_translation
[ [ "67", "True" ], [ "77", "True" ], [ "35", "False" ], [ "79", "False" ], [ "45", "True" ], [ "22", "True" ], [ "68", "False" ], [ "17", "False" ], [ "5", "True" ], [ "85", "False" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int a [ ], int n ) { int zero = 0, two = 0; for ( int i = 0; i < n; i ++ ) { if ( a [ i ] == 0 ) { zero ++; } if ( a [ i ] == 2 ) { two ++; } } int cnt = ( zero * ( zero - 1 ) ) / 2 + ( two * ( two - 1 ) ) / 2; return cnt; }
[]
null
[]
LONGEST_REPEATED_SUBSEQUENCE_1
python
[]
def f_gold ( str ) : n = len ( str ) dp = [ [ 0 for i in range ( n + 1 ) ] for j in range ( 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 ] ) res = '' i = n j = n while ( i > 0 and j > 0 ) : if ( dp [ i ] [ j ] == dp [ i - 1 ] [ j - 1 ] + 1 ) : res += str [ i - 1 ] i -= 1 j -= 1 elif ( dp [ i ] [ j ] == dp [ i - 1 ] [ j ] ) : i -= 1 else : j -= 1 res = ''.join ( reversed ( res ) ) return res
code_translation
[ [ "'qnQxjoRx'", "'x'" ], [ "'27473733400077'", "'7733007'" ], [ "'000010111111'", "'0000111111'" ], [ "'TNVwgrWSLu'", "''" ], [ "'9537'", "''" ], [ "'1100'", "'10'" ], [ "'lYcoiQfzN'", "''" ], [ "'52'", "''" ], [ "'0...
transcoder-geeksforgeeks
cpp
f_gold
null
[ "import math" ]
null
[]
NUMBER_UNIQUE_RECTANGLES_FORMED_USING_N_UNIT_SQUARES
python
[]
import math def f_gold ( n ) : ans = 0 for length in range ( 1 , int ( math.sqrt ( n ) ) + 1 ) : height = length while ( height * length <= n ) : ans += 1 height += 1 return ans
code_translation
[ [ "34", "66" ], [ "49", "104" ], [ "41", "83" ], [ "17", "28" ], [ "67", "151" ], [ "38", "76" ], [ "59", "128" ], [ "64", "144" ], [ "61", "135" ], [ "58", "127" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int n, int a = 0, int b = 1 ) { if ( n == 0 ) return a; if ( n == 1 ) return b; return f_gold ( n - 1, b, a + b ); }
[]
null
[]
POSITION_ELEMENT_STABLE_SORT
python
[]
def f_gold ( arr , n , idx ) : result = 0 for i in range ( n ) : if ( arr [ i ] < arr [ idx ] ) : result += 1 if ( arr [ i ] == arr [ idx ] and i < idx ) : result += 1 return result ;
code_translation
[ [ "[4, 8, 9, 12, 15, 16, 18, 28, 28, 31, 33, 36, 36, 37, 40, 41, 44, 44, 46, 50, 50, 50, 52, 52, 54, 55, 60, 61, 65, 68, 71, 75, 75, 78, 81, 84, 87, 89, 90, 92, 94, 97, 97, 98, 98, 99], 37, 32", "32" ], [ "[-16, 86, 94, -86, -38, 64, 96, -64, 94, 10, -10, -62, -50, -46, -62, -32, -4, 72, 14, 36, 74,...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; bool f_gold ( int x, int y ) { return ( ( x ^ y ) < 0 ); }
[]
null
[]
NUMBER_SUBSTRINGS_DIVISIBLE_4_STRING_INTEGERS
python
[]
def f_gold ( s ) : n = len ( s ) count = 0 ; for i in range ( 0 , n , 1 ) : if ( s [ i ] == '4' or s [ i ] == '8' or s [ i ] == '0' ) : count += 1 for i in range ( 0 , n - 1 , 1 ) : h = ( ord ( s [ i ] ) - ord ( '0' ) ) * 10 + ( ord ( s [ i + 1 ] ) - ord ( '0' ) ) if ( h % 4 == 0 ) : count = count + i + 1 return count
code_translation
[ [ "'Qaq'", "0" ], [ "'9400761825850'", "16" ], [ "'0011001111'", "10" ], [ "'lasWqrLRq'", "11" ], [ "'5662'", "1" ], [ "'110'", "1" ], [ "' tOYKf'", "6" ], [ "'6536991235305'", "11" ], [ "'11111'", "0" ], [ ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int n ) { int x = 0, yCount, res = 0; for ( yCount = 0; yCount * yCount < n; yCount ++ ); while ( yCount != 0 ) { res += yCount; x ++; while ( yCount != 0 && ( x * x + ( yCount - 1 ) * ( yCount - 1 ) >= n ) ) yCount --; } return res; }
[]
null
[]
SQUARE_ROOT_OF_A_PERFECT_SQUARE
python
[]
def f_gold ( n ) : x = n y = 1 e = 0.000001 while ( x - y > e ) : x = ( x + y ) / 2 y = n / x return x
code_translation
[ [ "1763.655093333857", "41.99589376968351" ], [ "-3544.737136289062", "-3544.737136289062" ], [ "7893.209433000695", "88.84373605423394" ], [ "-3008.0331952533734", "-3008.0331952533734" ], [ "6155.190186637041", "78.45502015008492" ], [ "-5799.7514673...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int a [ ], int n ) { int result = 1; for ( int i = 1; i <= n; ++ i ) { long long y = ( i * ( i + 1 ) ) / 2; if ( y < n ) result = i; else break; } return result; }
[]
null
[]
EFFICIENT_WAY_TO_MULTIPLY_WITH_7
python
[]
def f_gold ( n ) : return ( ( n << 3 ) - n )
code_translation
[ [ "41", "287" ], [ "42", "294" ], [ "62", "434" ], [ "4", "28" ], [ "31", "217" ], [ "75", "525" ], [ "5", "35" ], [ "75", "525" ], [ "85", "595" ], [ "19", "133" ] ]
transcoder-geeksforgeeks
cpp
f_gold
null
[]
null
[]
MAXIMUM_BINOMIAL_COEFFICIENT_TERM_VALUE
python
[]
def f_gold ( n ) : C = [ [ 0 for x in range ( n + 1 ) ] for y in range ( n + 1 ) ] ; for i in range ( n + 1 ) : for j in range ( 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 ] ) ; maxvalue = 0 ; for i in range ( n + 1 ) : maxvalue = max ( maxvalue , C [ n ] [ i ] ) ; return maxvalue ;
code_translation
[ [ "23", "1352078" ], [ "41", "269128937220" ], [ "69", "56093138908331422716" ], [ "56", "7648690600760440" ], [ "71", "221256270138418389602" ], [ "38", "35345263800" ], [ "26", "10400600" ], [ "52", "495918532948104" ], ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; string f_gold ( string num ) { int n = num . size ( ); int rightMin [ n ], right; rightMin [ n - 1 ] = - 1; right = n - 1; for ( int i = n - 2; i >= 1; i -- ) { if ( num [ i ] >= num [ right ] ) rightMin [ i ] = right; else { if ( num [ i ] == num [ i + 1 ] ) { rightMin [ i ] = right; } else { rightMin [ i ] = - 1; right = i; } } } int small = - 1; for ( int i = 1; i < n; i ++ ) if ( num [ i ] != '0' ) { if ( small == - 1 ) { if ( num [ i ] < num [ 0 ] ) small = i; } else if ( num [ i ] <= num [ small ] ) small = i; } if ( small != - 1 ) swap ( num [ 0 ], num [ small ] ); else { for ( int i = 1; i < n; i ++ ) { if ( rightMin [ i ] != - 1 && num [ i ] != num [ rightMin [ i ] ] ) { swap ( num [ i ], num [ rightMin [ i ] ] ); break; } } } return num; }
[]
null
[]
PROGRAM_TO_FIND_THE_VOLUME_OF_A_TRIANGULAR_PRISM
python
[]
def f_gold ( l , b , h ) : return ( ( l * b * h ) / 2 )
code_translation
[ [ "8448.900678262902, 8135.461799983198, 6577.239053611328", "226045593884.95786" ], [ "-1849.728957491451, -4240.89241631363, -9953.518310747193", "-39040194699.58562" ], [ "412.667844022232, 9798.083992381831, 1449.9204200270522", "2931270907.5877957" ], [ "-5954.8359117653...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int n ) { int a [ n ], b [ n ]; a [ 0 ] = b [ 0 ] = 1; for ( int i = 1; i < n; i ++ ) { a [ i ] = a [ i - 1 ] + b [ i - 1 ]; b [ i ] = a [ i - 1 ]; } return a [ n - 1 ] + b [ n - 1 ]; }
[]
null
[]
MINIMUM_TIME_TO_FINISH_TASKS_WITHOUT_SKIPPING_TWO_CONSECUTIVE
python
[]
def f_gold(arr, n): if (n <= 0): return 0 incl = arr[0] excl = 0 for i in range(1, n): incl_new = arr[i] + min(excl, incl) excl_new = incl incl = incl_new excl = excl_new return min(incl, excl)
code_translation
[ [ "[5, 17, 25, 27, 29, 30, 34, 49, 72, 75, 90, 93, 93, 94], 8", "93" ], [ "[-70, -32, 62, 0, -10, 92, -94, -86, 52, 6, -26, -92, -10, 70, -82, 28, 86, 58, 86, -58, 84, -80, -18, -92, -34, 6, 34, 36, 70, -50, -6, -54, 84, 22, 30, -96, -84, 72, 2, 26, -20, 4, 48, -98, 62, -28, -68], 36", "-834" ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; bool f_gold ( string num ) { if ( num . length ( ) >= 3 ) { int d1 = ( int ) num [ num . length ( ) - 1 ]; if ( d1 % 2 != 0 ) return ( 0 ); int d2 = ( int ) num [ num . length ( ) - 2 ]; int sum = 0; for ( int i = 0; i < num . length ( ); i ++ ) sum += num [ i ]; return ( sum % 3 == 0 && ( d2 * 10 + d1 ) % 4 == 0 ); } else { int number = stoi ( num ); return ( number % 12 == 0 ); } }
[ "import math" ]
null
[]
PROGRAM_FOR_SURFACE_AREA_OF_OCTAHEDRON
python
[]
import math def f_gold ( side ) : return ( 2 * ( math.sqrt ( 3 ) ) * ( side * side ) )
code_translation
[ [ "1449.255716877097", "7275798.574924052" ], [ "-8772.104874265995", "266562009.34357828" ], [ "2948.419328234334", "30114046.875937637" ], [ "-1184.220109553511", "4857977.358664159" ], [ "7422.825800698956", "190866258.51879707" ], [ "-5808.28000617...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; bool f_gold ( int r, int R, int r1, int x1, int y1 ) { int dis = sqrt ( x1 * x1 + y1 * y1 ); return ( dis - r1 >= R && dis + r1 <= r ); }
[]
null
[]
CHECK_OCCURRENCES_CHARACTER_APPEAR_TOGETHER
python
[]
def f_gold ( s , c ) : oneSeen = False i = 0 n = len ( s ) while ( i < n ) : if ( s [ i ] == c ) : if ( oneSeen == True ) : return False while ( i < n and s [ i ] == c ) : i = i + 1 oneSeen = True else : i = i + 1 return True
code_translation
[ [ "'gILrzLimS', 'm'", "True" ], [ "'307471222', '2'", "True" ], [ "'110', '0'", "True" ], [ "'GcAB', 'v'", "True" ], [ "'113', '3'", "True" ], [ "'011110010', '0'", "False" ], [ "'wcwob', 'w'", "False" ], [ "'74571582216153', '1...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( string X, string Y ) { int m = X . length ( ); int n = Y . length ( ); int result = 0; int len [ 2 ] [ n ]; int currRow = 0; for ( int i = 0; i <= m; i ++ ) { for ( int j = 0; j <= n; j ++ ) { if ( i == 0 || j == 0 ) { len [ currRow ] [ j ] = 0; } else if ( X [ i - 1 ] == Y [ j - 1 ] ) { len [ currRow ] [ j ] = len [ 1 - currRow ] [ j - 1 ] + 1; result = max ( result, len [ currRow ] [ j ] ); } else { len [ currRow ] [ j ] = 0; } } currRow = 1 - currRow; } return result; }
[]
null
[]
MINIMUM_DIFFERENCE_BETWEEN_GROUPS_OF_SIZE_TWO
python
[]
def f_gold ( a , n ) : a.sort ( ) ; s = [ ] ; i = 0 ; j = n - 1 ; while ( i < j ) : s.append ( ( a [ i ] + a [ j ] ) ) ; i += 1 ; j -= 1 ; mini = min ( s ) ; maxi = max ( s ) ; return abs ( maxi - mini ) ;
code_translation
[ [ "[11, 12, 14, 15, 20, 21, 28, 28, 30, 33, 39, 39, 42, 43, 44, 45, 48, 53, 53, 58, 59, 67, 68, 70, 70, 72, 74, 76, 76, 81, 87, 91], 31", "10" ], [ "[-94, -84, -70, -62, -60, -56, -44, -42, -30, -14, -14, -12, 0, 14, 18, 28, 42, 52, 58, 58, 88, 92], 11", "10" ], [ "[0, 0, 0, 0, 0, 0, 0, ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int a, int b ) { return ( a / 2 ) + ( b / 2 ) + ( ( a % 2 + b % 2 ) / 2 ); }
[]
null
[]
PROGRAM_TO_CHECK_IF_A_MATRIX_IS_SYMMETRIC
python
[]
def f_gold ( mat , N ) : for i in range ( N ) : for j in range ( N ) : if ( mat [ i ] [ j ] != mat [ j ] [ i ] ) : return False return True
code_translation
[ [ "[[29]], 0", "True" ], [ "[[1, 3, 5], [3, 2, 4], [5, 4, 1]], 3", "True" ], [ "[[1, 2, 5], [3, 2, 4], [5, 4, 1]], 3", "False" ], [ "[[37, 56, 39, 95, 78, 69, 89, 45, 66, 99, 20, 10, 6, 33, 78, 26, 86, 61, 78, 36, 62, 23, 80, 89, 83], [42, 75, 30, 64, 25, 95, 17, 90, 6, 11, 1...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int side ) { int area = side * side; return area; }
[ "import math" ]
null
[]
FIND_MINIMUM_NUMBER_DIVIDED_MAKE_NUMBER_PERFECT_SQUARE
python
[]
import math def f_gold ( n ) : count = 0 ans = 1 while n % 2 == 0 : count += 1 n //= 2 if count % 2 is not 0 : ans *= 2 for i in range ( 3 , ( int ) ( math.sqrt ( n ) ) + 1 , 2 ) : count = 0 while n % i == 0 : count += 1 n //= i if count % 2 is not 0 : ans *= i if n > 2 : ans *= n return ans
code_translation
[ [ "95", "95" ], [ "48", "3" ], [ "3", "3" ], [ "10", "10" ], [ "82", "82" ], [ "1", "1" ], [ "77", "77" ], [ "99", "11" ], [ "23", "23" ], [ "61", "61" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int arr [ ], int N, int K ) { sort ( arr, arr + N ); int dp [ N ]; dp [ 0 ] = 0; for ( int i = 1; i < N; i ++ ) { dp [ i ] = dp [ i - 1 ]; if ( arr [ i ] - arr [ i - 1 ] < K ) { if ( i >= 2 ) dp [ i ] = max ( dp [ i ], dp [ i - 2 ] + arr [ i ] + arr [ i - 1 ] ); else dp [ i ] = max ( dp [ i ], arr [ i ] + arr [ i - 1 ] ); } } return dp [ N - 1 ]; }
[]
null
[]
FIND_SUM_NON_REPEATING_DISTINCT_ELEMENTS_ARRAY
python
[]
def f_gold ( arr , n ) : s = set ( ) sum = 0 for i in range ( n ) : if arr [ i ] not in s : s.add ( arr [ i ] ) for i in s : sum = sum + i return sum
code_translation
[ [ "[5, 6, 8, 10, 21, 22, 27, 32, 35, 36, 43, 44, 46, 48, 49, 55, 60, 61, 69, 69, 71, 72, 73, 78, 88, 94], 24", "971" ], [ "[80, 94, 16, -74, 32, -64, -84, -66, -10], 6", "84" ], [ "[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], 27", "1"...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; float f_gold ( int a ) { float area = ( M_PI * a * a ) / 4.0; return area; }
[]
null
[]
C_PROGRAM_FACTORIAL_NUMBER
python
[]
def f_gold ( n ) : return 1 if ( n == 1 or n == 0 ) else n * f_gold ( n - 1 ) ;
code_translation
[ [ "84", "3314240134565353266999387579130131288000666286242049487118846032383059131291716864129885722968716753156177920000000000000000000" ], [ "41", "33452526613163807108170062053440751665152000000000" ], [ "5", "120" ], [ "38", "523022617466601111760007224100074291200000...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int x ) { return ( x << 1 ) + x + ( x >> 1 ); }
[]
null
[]
FORM_MINIMUM_NUMBER_FROM_GIVEN_SEQUENCE_1
python
[]
def f_gold ( seq ) : n = len ( seq ) if ( n >= 9 ) : return "-1" result = [ None ] * ( n + 1 ) count = 1 for i in range ( n + 1 ) : if ( i == n or seq [ i ] == 'I' ) : for j in range ( i - 1 , - 2 , - 1 ) : result [ j + 1 ] = int ( '0' + str ( count ) ) count += 1 if ( j >= 0 and seq [ j ] == 'I' ) : break return result
code_translation
[ [ "'D'", "[2, 1]" ], [ "'I'", "[1, 2]" ], [ "'DD'", "[3, 2, 1]" ], [ "'II'", "[1, 2, 3]" ], [ "'DIDI'", "[2, 1, 4, 3, 5]" ], [ "'IIDDD'", "[1, 2, 6, 5, 4, 3]" ], [ "'DDIDDIID'", "[3, 2, 1, 6, 5, 4, 7, 9, 8]" ], [ "'176297'", ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int arr [ ], int N, int k ) { int MS [ N ]; MS [ N - 1 ] = arr [ N - 1 ]; for ( int i = N - 2; i >= 0; i -- ) { if ( i + k + 1 >= N ) MS [ i ] = max ( arr [ i ], MS [ i + 1 ] ); else MS [ i ] = max ( arr [ i ] + MS [ i + k + 1 ], MS [ i + 1 ] ); } return MS [ 0 ]; }
[]
null
[]
FIND_MAXIMUM_SUM_POSSIBLE_EQUAL_SUM_THREE_STACKS
python
[]
def f_gold ( stack1 , stack2 , stack3 , n1 , n2 , n3 ) : sum1 , sum2 , sum3 = 0 , 0 , 0 for i in range ( n1 ) : sum1 += stack1 [ i ] for i in range ( n2 ) : sum2 += stack2 [ i ] for i in range ( n3 ) : sum3 += stack3 [ i ] top1 , top2 , top3 = 0 , 0 , 0 ans = 0 while ( 1 ) : if ( top1 == n1 or top2 == n2 or top3 == n3 ) : return 0 if ( sum1 == sum2 and sum2 == sum3 ) : return sum1 if ( sum1 >= sum2 and sum1 >= sum3 ) : sum1 -= stack1 [ top1 ] top1 = top1 + 1 elif ( sum2 >= sum3 and sum2 >= sum3 ) : sum2 -= stack2 [ top2 ] top2 = top2 + 1 elif ( sum3 >= sum2 and sum3 >= sum1 ) : sum3 -= stack3 [ top3 ] top3 = top3 + 1
code_translation
[ [ "[4, 10, 11, 24, 27, 33, 34, 36, 36, 40, 42, 43, 52, 58, 67, 69, 77, 86, 86, 88], [4, 13, 34, 40, 41, 47, 47, 52, 55, 62, 66, 66, 69, 70, 73, 74, 75, 76, 85, 98], [6, 8, 10, 12, 14, 29, 41, 52, 53, 54, 55, 66, 69, 73, 77, 77, 78, 80, 90, 99], 10, 12, 18", "0" ], [ "[40, 54, 14, 58, -64, -60, -98, ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( char str [ ], int l, int h ) { if ( l > h ) return INT_MAX; if ( l == h ) return 0; if ( l == h - 1 ) return ( str [ l ] == str [ h ] ) ? 0 : 1; return ( str [ l ] == str [ h ] ) ? f_gold ( str, l + 1, h - 1 ) : ( min ( f_gold ( str, l, h - 1 ), f_gold ( str, l + 1, h ) ) + 1 ); }
[]
null
[]
FIND_SUM_MODULO_K_FIRST_N_NATURAL_NUMBER
python
[]
def f_gold ( N , K ) : ans = 0 ; for i in range ( 1 , N + 1 ) : ans += ( i % K ) ; return ans ;
code_translation
[ [ "11, 5", "21" ], [ "36, 69", "666" ], [ "71, 28", "876" ], [ "74, 1", "0" ], [ "66, 84", "2211" ], [ "38, 14", "237" ], [ "2, 11", "3" ], [ "73, 87", "2701" ], [ "79, 11", "388" ], [ "30, 55", "465"...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int arr [ ], int l, int r, int x ) { if ( r >= l ) { int mid = l + ( r - l ) / 2; if ( arr [ mid ] == x ) return mid; if ( mid > l && arr [ mid - 1 ] == x ) return ( mid - 1 ); if ( mid < r && arr [ mid + 1 ] == x ) return ( mid + 1 ); if ( arr [ mid ] > x ) return f_gold ( arr, l, mid - 2, x ); return f_gold ( arr, mid + 2, r, x ); } return - 1; }
[]
null
[]
MAXIMUM_NUMBER_CHARACTERS_TWO_CHARACTER_STRING
python
[]
def f_gold ( str ) : n = len ( str ) res = - 1 for i in range ( 0 , n - 1 ) : for j in range ( i + 1 , n ) : if ( str [ i ] == str [ j ] ) : res = max ( res , abs ( j - i - 1 ) ) return res
code_translation
[ [ "'cI'", "-1" ], [ "'76478'", "2" ], [ "'1'", "-1" ], [ "'tr'", "-1" ], [ "'10'", "-1" ], [ "'01'", "-1" ], [ "'Rmhzp'", "-1" ], [ "'5784080133917'", "10" ], [ "'1100'", "0" ], [ "'OK'", "-1" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int n ) { return 0.6172 * ( pow ( 10, n ) - 1 ) - 0.55 * n; }
[ "from math import floor" ]
null
[]
COMPUTE_AVERAGE_TWO_NUMBERS_WITHOUT_OVERFLOW
python
[]
from math import floor def f_gold ( a , b ) : return floor ( ( a + b ) / 2 )
code_translation
[ [ "1, 44", "22" ], [ "6, 61", "33" ], [ "75, 20", "47" ], [ "51, 17", "34" ], [ "19, 25", "22" ], [ "82, 98", "90" ], [ "72, 21", "46" ], [ "48, 41", "44" ], [ "12, 17", "14" ], [ "41, 80", "60" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; unsigned long long f_gold ( int n ) { return ( n * ( n + 1 ) / 2 ) * ( 1 << ( n - 1 ) ); }
[]
null
[]
COST_BALANCE_PARANTHESES
python
[]
def f_gold ( s ) : if ( len ( s ) == 0 ) : print ( 0 ) ans = 0 o = 0 c = 0 for i in range ( len ( s ) ) : if ( s [ i ] == '(' ) : o += 1 if ( s [ i ] == ')' ) : c += 1 if ( o != c ) : return - 1 a = [ 0 for i in range ( len ( s ) ) ] if ( s [ 0 ] == '(' ) : a [ 0 ] = 1 else : a [ 0 ] = - 1 if ( a [ 0 ] < 0 ) : ans += abs ( a [ 0 ] ) for i in range ( 1 , len ( s ) ) : if ( s [ i ] == '(' ) : a [ i ] = a [ i - 1 ] + 1 else : a [ i ] = a [ i - 1 ] - 1 if ( a [ i ] < 0 ) : ans += abs ( a [ i ] ) return ans
code_translation
[ [ "'()'", "0" ], [ "'))(('", "4" ], [ "'())'", "-1" ], [ "'(()'", "-1" ], [ "'(()()())'", "0" ], [ "'))())(()(())'", "-1" ], [ "'))(())(('", "8" ], [ "'49'", "3" ], [ "'00001111'", "36" ], [ "'KDahByG '",...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int num, int divisor ) { if ( divisor == 0 ) { cout << "Error: divisor can't be zero \n"; return - 1; } if ( divisor < 0 ) divisor = - divisor; if ( num < 0 ) num = - num; int i = 1; int product = 0; while ( product <= num ) { product = divisor * i; i ++; } return num - ( product - divisor ); }
[]
null
[]
PROGRAM_FIND_SMALLEST_DIFFERENCE_ANGLES_TWO_PARTS_GIVEN_CIRCLE
python
[]
def f_gold ( arr , n ) : l = 0 _sum = 0 ans = 360 for i in range ( n ) : _sum += arr [ i ] while _sum >= 180 : ans = min ( ans , 2 * abs ( 180 - _sum ) ) _sum -= arr [ l ] l += 1 ans = min ( ans , 2 * abs ( 180 - _sum ) ) return ans
code_translation
[ [ "[4, 4, 5, 5, 13, 14, 14, 16, 19, 20, 30, 31, 32, 33, 35, 38, 38, 42, 44, 44, 48, 48, 52, 58, 60, 64, 65, 66, 68, 69, 70, 70, 71, 72, 73, 79, 81, 83, 83, 84, 86, 87, 88, 88, 91, 92, 95, 95, 98], 27", "2" ], [ "[-56, 88, -50, 70, 20, 58, 42, -56, -52, -78, 98, 20, -26, 4, 20, -66, -46, -58, 74, 74,...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; bool f_gold ( int n ) { if ( n <= 1 ) return false; if ( n <= 3 ) return false; if ( n % 2 == 0 || n % 3 == 0 ) return true; for ( int i = 5; i * i <= n; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return true; return false; }
[]
null
[]
WRITE_ONE_LINE_C_FUNCTION_TO_FIND_WHETHER_A_NO_IS_POWER_OF_TWO_1
python
[]
def f_gold ( x ) : return ( x and ( not ( x & ( x - 1 ) ) ) )
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 pages [ ], int n, int capacity ) { unordered_set < int > s; queue < int > indexes; int page_faults = 0; for ( int i = 0; i < n; i ++ ) { if ( s . size ( ) < capacity ) { if ( s . find ( pages [ i ] ) == s . end ( ) ) { s . insert ( pages [ i ] ); page_faults ++; indexes . push ( pages [ i ] ); } } else { if ( s . find ( pages [ i ] ) == s . end ( ) ) { int val = indexes . front ( ); indexes . pop ( ); s . erase ( val ); s . insert ( pages [ i ] ); indexes . push ( pages [ i ] ); page_faults ++; } } } return page_faults; }
[ "import math" ]
null
[]
HARDY_RAMANUJAN_THEOREM
python
[]
import math def f_gold ( n ) : count = 0 if ( n % 2 == 0 ) : count = count + 1 while ( n % 2 == 0 ) : n = int ( n / 2 ) i = 3 while ( i <= int ( math.sqrt ( n ) ) ) : if ( n % i == 0 ) : count = count + 1 while ( n % i == 0 ) : n = int ( n / i ) i = i + 2 if ( n > 2 ) : count = count + 1 return count
code_translation
[ [ "99", "2" ], [ "33", "2" ], [ "50", "2" ], [ "17", "1" ], [ "18", "2" ], [ "69", "2" ], [ "23", "1" ], [ "18", "2" ], [ "94", "2" ], [ "16", "1" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int arr [ ], int n ) { int maxA = INT_MIN, maxB = INT_MIN, maxC = INT_MIN; for ( int i = 0; i < n; i ++ ) { if ( arr [ i ] > maxA ) { maxC = maxB; maxB = maxA; maxA = arr [ i ]; } else if ( arr [ i ] > maxB ) { maxC = maxB; maxB = arr [ i ]; } else if ( arr [ i ] > maxC ) maxC = arr [ i ]; } return ( maxA + maxB + maxC ); }
[]
null
[]
GCD_ELEMENTS_GIVEN_RANGE
python
[]
def f_gold ( n , m ) : return n if ( n == m ) else 1
code_translation
[ [ "57, 57", "57" ], [ "22, 22", "22" ], [ "17, 17", "17" ], [ "74, 74", "74" ], [ "93, 22", "1" ], [ "56, 54", "1" ], [ "5, 33", "1" ], [ "5, 68", "1" ], [ "9, 75", "1" ], [ "98, 21", "1" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; double f_gold ( double side ) { return ( float ) ( 2 * ( 1 + sqrt ( 2 ) ) * side * side ); }
[]
null
[]
FIND_MINIMUM_SUM_FACTORS_NUMBER
python
[]
def f_gold ( num ) : sum = 0 i = 2 while ( i * i <= num ) : while ( num % i == 0 ) : sum += i num /= i i += 1 sum += num return sum
code_translation
[ [ "83", "83" ], [ "88", "17.0" ], [ "60", "12.0" ], [ "6", "5.0" ], [ "26", "15.0" ], [ "98", "17.0" ], [ "38", "21.0" ], [ "90", "13.0" ], [ "76", "23.0" ], [ "66", "16.0" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; double f_gold ( double side ) { return ( ( side * side * side ) * ( sqrt ( 2 ) / 3 ) ); }
[]
null
[]
PROBABILITY_THREE_RANDOMLY_CHOSEN_NUMBERS_AP
python
[]
def f_gold ( n ) : return ( 3.0 * n ) / ( 4.0 * ( n * n ) - 1 )
code_translation
[ [ "46", "0.0163062743707905" ], [ "5", "0.15151515151515152" ], [ "44", "0.017047655947307245" ], [ "15", "0.05005561735261402" ], [ "72", "0.010417169037858692" ], [ "2", "0.4" ], [ "86", "0.008721225027887637" ], [ "17", "...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int arr [ ], int low, int high, int key ) { if ( high < low ) return - 1; int mid = ( low + high ) / 2; if ( key == arr [ mid ] ) return mid; if ( key > arr [ mid ] ) return f_gold ( arr, ( mid + 1 ), high, key ); return f_gold ( arr, low, ( mid - 1 ), key ); }
[]
null
[]
GOLD_MINE_PROBLEM
python
[]
def f_gold ( gold , m , n ) : goldTable = [ [ 0 for i in range ( n ) ] for j in range ( m ) ] for col in range ( n - 1 , - 1 , - 1 ) : for row in range ( m ) : if ( col == n - 1 ) : right = 0 else : right = goldTable [ row ] [ col + 1 ] if ( row == 0 or col == n - 1 ) : right_up = 0 else : right_up = goldTable [ row - 1 ] [ col + 1 ] if ( row == m - 1 or col == n - 1 ) : right_down = 0 else : right_down = goldTable [ row + 1 ] [ col + 1 ] goldTable [ row ] [ col ] = gold [ row ] [ col ] + max ( right , right_up , right_down ) res = goldTable [ 0 ] [ 0 ] for i in range ( 1 , m ) : res = max ( res , goldTable [ i ] [ 0 ] ) return res
code_translation
[ [ "[[19, 20, 23, 25, 28, 35, 35, 40, 45, 46, 48, 54, 57, 59, 74, 76, 78, 82, 84, 86, 87, 90, 91, 96], [9, 13, 17, 20, 26, 27, 42, 46, 48, 62, 67, 69, 72, 73, 76, 77, 82, 83, 86, 93, 95, 95, 98, 98], [2, 12, 18, 25, 29, 30, 31, 33, 39, 45, 48, 49, 56, 57, 60, 61, 64, 72, 73, 78, 79, 94, 98, 98], [2, 3, 10, 15, 2...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int n, int a, int b, int c ) { int dp [ n + 1 ]; memset ( dp, - 1, sizeof ( dp ) ); dp [ 0 ] = 0; for ( int i = 0; i < n; i ++ ) { if ( dp [ i ] != - 1 ) { if ( i + a <= n ) dp [ i + a ] = max ( dp [ i ] + 1, dp [ i + a ] ); if ( i + b <= n ) dp [ i + b ] = max ( dp [ i ] + 1, dp [ i + b ] ); if ( i + c <= n ) dp [ i + c ] = max ( dp [ i ] + 1, dp [ i + c ] ); } } return dp [ n ]; }
[ "import math" ]
null
[]
SUM_OF_ALL_PROPER_DIVISORS_OF_A_NATURAL_NUMBER
python
[]
import math def f_gold ( num ) : result = 0 i = 2 while i <= ( math.sqrt ( num ) ) : if ( num % i == 0 ) : if ( i == ( num / i ) ) : result = result + i ; else : result = result + ( i + num / i ) ; i = i + 1 return ( result + 1 ) ;
code_translation
[ [ "2", "1" ], [ "57", "23.0" ], [ "28", "28.0" ], [ "43", "1" ], [ "38", "22.0" ], [ "29", "1" ], [ "45", "33.0" ], [ "47", "1" ], [ "44", "40.0" ], [ "3", "1" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int dist ) { int count [ dist + 1 ]; count [ 0 ] = 1, count [ 1 ] = 1, count [ 2 ] = 2; for ( int i = 3; i <= dist; i ++ ) count [ i ] = count [ i - 1 ] + count [ i - 2 ] + count [ i - 3 ]; return count [ dist ]; }
[]
null
[]
COUNT_WAYS_DIVIDE_CIRCLE_USING_N_NON_INTERSECTING_CHORDS
python
[]
def f_gold ( A ) : n = 2 * A dpArray = [ 0 ] * ( n + 1 ) dpArray [ 0 ] = 1 dpArray [ 2 ] = 1 for i in range ( 4 , n + 1 , 2 ) : for j in range ( 0 , i - 1 , 2 ) : dpArray [ i ] += ( dpArray [ j ] * dpArray [ i - 2 - j ] ) return int ( dpArray [ n ] )
code_translation
[ [ "32", "55534064877048198" ], [ "52", "29869166945772625950142417512" ], [ "52", "29869166945772625950142417512" ], [ "32", "55534064877048198" ], [ "73", "79463489365077377841208237632349268884500" ], [ "31", "14544636039226909" ], [ "29"...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int a, int b, int c ) { if ( a > b ) { if ( b > c ) return b; else if ( a > c ) return c; else return a; } else { if ( a > c ) return a; else if ( b > c ) return c; else return b; } }
[]
null
[]
FIND_SUM_UNIQUE_SUB_ARRAY_SUM_GIVEN_ARRAY
python
[]
def f_gold ( arr , n ) : res = 0 m = dict ( ) for i in range ( n ) : Sum = 0 for j in range ( i , n ) : Sum += arr [ j ] m [ Sum ] = m.get ( Sum , 0 ) + 1 for x in m : if m [ x ] == 1 : res += x return res
code_translation
[ [ "[7, 24, 34, 35, 36, 40, 49, 51, 53, 74, 78], 9", "5631" ], [ "[-34, 60, 32], 2", "52" ], [ "[0], 0", "0" ], [ "[80, 64, 10, 82, 14, 75, 51, 91, 1, 25, 98, 22, 36, 27, 21, 31, 93, 6, 52, 91, 80, 8, 62, 95, 10, 71, 40, 80, 35, 86, 85, 26, 74, 72, 64, 88, 4, 71, 4, 16], 31", ...
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 len = 1; len <= N; len ++ ) { for ( int i = 0, j = len - 1; j < N; i ++, j ++ ) { if ( len == 1 ) dp [ i ] [ j ] = 1; else { dp [ i ] [ j ] = 1 + dp [ i + 1 ] [ j ]; if ( str [ i ] == str [ i + 1 ] ) dp [ i ] [ j ] = min ( 1 + dp [ i + 2 ] [ j ], dp [ i ] [ j ] ); for ( int K = i + 2; K <= j; K ++ ) if ( str [ i ] == str [ K ] ) dp [ i ] [ j ] = min ( dp [ i + 1 ] [ K - 1 ] + dp [ K + 1 ] [ j ], dp [ i ] [ j ] ); } } } return dp [ 0 ] [ N - 1 ]; }
[]
null
[]
FIND_N_TH_ELEMENT_FROM_STERNS_DIATOMIC_SERIES
python
[]
def f_gold ( n ) : DP = [ 0 ] * ( n + 1 ) DP [ 0 ] = 0 DP [ 1 ] = 1 for i in range ( 2 , n + 1 ) : if ( int ( i % 2 ) == 0 ) : DP [ i ] = DP [ int ( i / 2 ) ] else : DP [ i ] = ( DP [ int ( ( i - 1 ) / 2 ) ] + DP [ int ( ( i + 1 ) / 2 ) ] ) return DP [ n ]
code_translation
[ [ "37", "11" ], [ "24", "2" ], [ "13", "5" ], [ "56", "3" ], [ "26", "5" ], [ "67", "11" ], [ "82", "11" ], [ "60", "4" ], [ "64", "1" ], [ "65", "7" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int high [ ], int low [ ], int n ) { if ( n <= 0 ) return 0; return max ( high [ n - 1 ] + f_gold ( high, low, ( n - 2 ) ), low [ n - 1 ] + f_gold ( high, low, ( n - 1 ) ) ); }
[]
null
[]
MAXIMUM_VALUE_CHOICE_EITHER_DIVIDING_CONSIDERING
python
[]
def f_gold ( n ) : res = list ( ) res.append ( 0 ) res.append ( 1 ) i = 2 while i < n + 1 : res.append ( max ( i , ( res [ int ( i / 2 ) ] + res [ int ( i / 3 ) ] + res [ int ( i / 4 ) ] + res [ int ( i / 5 ) ] ) ) ) i = i + 1 return res [ n ]
code_translation
[ [ "3", "3" ], [ "19", "24" ], [ "39", "57" ], [ "89", "152" ], [ "96", "192" ], [ "68", "114" ], [ "48", "83" ], [ "5", "5" ], [ "3", "3" ], [ "4", "4" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int N, int K ) { int ans = 0; int y = N / K; int x = N % K; ans = ( K * ( K - 1 ) / 2 ) * y + ( x * ( x + 1 ) ) / 2; return ans; }
[]
null
[]
NEXT_POWER_OF_2_1
python
[]
def f_gold ( n ) : p = 1 if ( n and not ( n & ( n - 1 ) ) ) : return n while ( p < n ) : p <<= 1 return p ;
code_translation
[ [ "8", "8" ], [ "79", "128" ], [ "31", "32" ], [ "63", "64" ], [ "18", "32" ], [ "2", "2" ], [ "6", "8" ], [ "85", "128" ], [ "29", "32" ], [ "8", "8" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int n ) { int l = sqrt ( n ); int sq = l * l; if ( sq == n ) return l * 4; else { long long int row = n / l; long long int perimeter = 2 * ( l + row ); if ( n % l != 0 ) perimeter += 2; return perimeter; } }
[]
null
[]
COUNT_PAIRS_DIFFERENCE_EQUAL_K
python
[]
def f_gold ( arr , n , k ) : count = 0 for i in range ( 0 , n ) : for j in range ( i + 1 , n ) : if arr [ i ] - arr [ j ] == k or arr [ j ] - arr [ i ] == k : count += 1 return count
code_translation
[ [ "[9, 14, 17, 19, 22, 23, 23, 27, 30, 31, 34, 37, 37, 39, 39, 42, 57, 61, 68, 73, 77, 79, 91, 96, 97], 19, 19", "3" ], [ "[-78, -42, 28, -88, 18, -52], 3, 4", "0" ], [ "[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1], 16, 14", "0" ], [ "[8, 46, 57, 28, 80, 2, 75, 57, 83,...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( unsigned int n ) { return n & ( n - 1 ); }
[]
null
[]
MINIMUM_STEPS_MINIMIZE_N_PER_GIVEN_CONDITION
python
[]
def f_gold ( n ) : table = [ 0 ] * ( n + 1 ) for i in range ( n + 1 ) : table [ i ] = n - i for i in range ( n , 0 , - 1 ) : if ( not ( i % 2 ) ) : table [ i // 2 ] = min ( table [ i ] + 1 , table [ i // 2 ] ) if ( not ( i % 3 ) ) : table [ i // 3 ] = min ( table [ i ] + 1 , table [ i // 3 ] ) return table [ 1 ]
code_translation
[ [ "59", "9" ], [ "7", "3" ], [ "90", "13" ], [ "78", "11" ], [ "49", "6" ], [ "15", "6" ], [ "45", "13" ], [ "56", "6" ], [ "7", "3" ], [ "70", "12" ] ]
transcoder-geeksforgeeks
cpp
f_gold
null
[]
null
[]
PROGRAM_FOR_FACTORIAL_OF_A_NUMBER_1
python
[]
def f_gold ( n ) : return 1 if ( n == 1 or n == 0 ) else n * f_gold ( n - 1 ) ;
code_translation
[ [ "57", "40526919504877216755680601905432322134980384796226602145184481280000000000000" ], [ "28", "304888344611713860501504000000" ], [ "23", "25852016738884976640000" ], [ "79", "8946182130782975286851441715398316520698082167795719072138680632278379906935018605333618108...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int arr [ ], int n ) { unordered_set < int > s; for ( int i = 0; i < n; i ++ ) { if ( s . find ( arr [ i ] ) != s . end ( ) ) return arr [ i ]; s . insert ( arr [ i ] ); } return - 1; }
[]
null
[]
PYTHAGOREAN_QUADRUPLE
python
[]
def f_gold ( a , b , c , d ) : sum = a * a + b * b + c * c ; if ( d * d == sum ) : return True else : return False
code_translation
[ [ "1, 1, 1, 3", "False" ], [ "3, 2, 5, 38", "False" ], [ "0, 0, 0, 0", "True" ], [ "-1, -1, -1, 1", "False" ], [ "82, 79, 6, 59", "False" ], [ "14, 57, 35, 29", "False" ], [ "6, 96, 45, 75", "False" ], [ "13, 7, 3, 63", "Fal...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int arr [ ], int n ) { int ans = INT_MIN; for ( int i = 0; i < n; i ++ ) { int curr_xor = 0; for ( int j = i; j < n; j ++ ) { curr_xor = curr_xor ^ arr [ j ]; ans = max ( ans, curr_xor ); } } return ans; }
[ "import math" ]
null
[]
PROGRAM_CHECK_PLUS_PERFECT_NUMBER
python
[]
import math def f_gold ( x ) : temp = x n = 0 while ( x != 0 ) : x = x // 10 n = n + 1 x = temp sm = 0 while ( x != 0 ) : sm = sm + ( int ) ( math.pow ( x % 10 , n ) ) x = x // 10 return ( sm == temp )
code_translation
[ [ "371", "True" ], [ "9474", "True" ], [ "85", "False" ], [ "35", "False" ], [ "54", "False" ], [ "17", "False" ], [ "97", "False" ], [ "63", "False" ], [ "12", "False" ], [ "43", "False" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; string f_gold ( string str ) { string result = ""; bool v = true; for ( int i = 0; i < str . length ( ); i ++ ) { if ( str [ i ] == ' ' ) v = true; else if ( str [ i ] != ' ' && v == true ) { result . push_back ( str [ i ] ); v = false; } } return result; }
[]
null
[]
MAXIMUM_SUBARRAY_SUM_ARRAY_CREATED_REPEATED_CONCATENATION
python
[]
def f_gold ( a , n , k ) : max_so_far = - 2147483648 max_ending_here = 0 for i in range ( n * k ) : max_ending_here = max_ending_here + a [ i % n ] if ( max_so_far < max_ending_here ) : max_so_far = max_ending_here if ( max_ending_here < 0 ) : max_ending_here = 0 return max_so_far
code_translation
[ [ "[5, 6, 12, 20, 23, 28, 33, 37, 47, 51, 53, 56, 63, 65, 65, 68, 69, 76, 76, 78, 83], 18, 20", "15540" ], [ "[68, 10, 52, -44, 34, -4, -34, 2, 50, -60, 50, 94, -98, -98, -44, -36, -4, -62, -2, -92, -70, -48, -78, -10, 94], 22, 22", "218" ], [ "[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 arr [ ], int n ) { int SubsetSum_1 = 0, SubsetSum_2 = 0; for ( int i = 0; i <= n - 1; i ++ ) { bool isSingleOccurance = true; for ( int j = i + 1; j <= n - 1; j ++ ) { if ( arr [ i ] == arr [ j ] ) { isSingleOccurance = false; arr [ i ] = arr [ j ] = 0; break; } } if ( isSingleOccurance ) { if ( arr [ i ] > 0 ) SubsetSum_1 += arr [ i ]; else SubsetSum_2 += arr [ i ]; } } return abs ( SubsetSum_1 - SubsetSum_2 ); }
[]
null
[]
FIND_WHETHER_AN_ARRAY_IS_SUBSET_OF_ANOTHER_ARRAY_SET_1
python
[]
def f_gold ( arr1 , arr2 , m , n ) : i = 0 j = 0 for i in range ( n ) : for j in range ( m ) : if ( arr2 [ i ] == arr1 [ j ] ) : break if ( j == m ) : return 0 return 1
code_translation
[ [ "[7, 10, 10, 10, 13, 17, 23, 24, 25, 28, 30, 33, 37, 49, 49, 50, 57, 60, 60, 63, 63, 64, 65, 65, 72, 81, 84, 85, 85, 94, 96], [10, 13, 17, 63], 29, 4", "1" ], [ "[12, 30, -94, -92, -62, -18, -56, 44, -50, -92, 6, 2, 56, -90, 0, 0, 18, 86, -58, 58, -54, 62, -94, 94, 0, 8, 82, -68, -88, -18, 8, -80,...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int n ) { int dp [ n + 1 ]; dp [ 0 ] = 0, dp [ 1 ] = 1; for ( int i = 2; i <= n; i ++ ) dp [ i ] = max ( dp [ i / 2 ] + dp [ i / 3 ] + dp [ i / 4 ], i ); return dp [ n ]; }
[]
null
[]
MAXIMUM_AREA_RECTANGLE_PICKING_FOUR_SIDES_ARRAY
python
[]
def f_gold ( arr , n ) : arr.sort ( reverse = True ) dimension = [ 0 , 0 ] i = 0 j = 0 while ( i < n - 1 and j < 2 ) : if ( arr [ i ] == arr [ i + 1 ] ) : dimension [ j ] = arr [ i ] j += 1 i += 1 i += 1 return ( dimension [ 0 ] * dimension [ 1 ] )
code_translation
[ [ "[99, 96, 95, 95, 92, 84, 83, 82, 81, 74, 72, 68, 67, 52, 51, 51, 49, 47, 44, 40, 36, 25, 24, 17, 16, 14, 12, 11, 9, 8, 6, 5, 1], 27", "4845" ], [ "[-32, -54, -82, -92], 2", "0" ], [ "[1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 15", "1" ], [ "[99, 96, 96, 94, 68...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int coin [ ], int n, int k ) { sort ( coin, coin + n ); int coins_needed = ceil ( 1.0 * n / ( k + 1 ) ); int ans = 0; for ( int i = 0; i <= coins_needed - 1; i ++ ) ans += coin [ i ]; return ans; }
[]
null
[]
INTEGER_POSITIVE_VALUE_POSITIVE_NEGATIVE_VALUE_ARRAY_1
python
[]
def f_gold ( arr , n ) : neg = 0 pos = 0 sum = 0 for i in range ( 0 , n ) : sum += arr [ i ] if ( arr [ i ] < 0 ) : neg += 1 else : pos += 1 return ( sum / abs ( neg - pos ) )
code_translation
[ [ "[49, 98], 1", "49.0" ], [ "[82, 66, -68, 24, -10], 2", "74.0" ], [ "[0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1], 8", "0.125" ], [ "[56, 3, 18, 5, 20, 56, 47, 29, 60, 98, 60, 40, 42, 2, 54, 56, 91, 8, 93, 14, 31, 27, 61, 49, 23, 12, 71], 25", "41.72" ], [ "[-94, ...