suffix
null
compare_func
listlengths
0
0
demos
listlengths
0
0
tgt_lang
stringclasses
1 value
task_name
stringclasses
1 value
solution
stringlengths
40
1.94k
src_lang
stringclasses
1 value
doc_string
stringclasses
1 value
test_cases
listlengths
10
11
entry_func
stringclasses
1 value
data_id
stringlengths
9
106
dataset_name
stringclasses
1 value
prefix
stringlengths
188
2.04k
import_str
listlengths
0
1
null
[]
[]
python
code_translation
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
java
[ [ "[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...
f_gold
MINIMUM_NUMBER_SUBSETS_DISTINCT_ELEMENTS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MINIMUM_NUMBER_SUBSETS_DISTINCT_ELEMENTS{ public static int f_gold ( int ar [ ] , int n ) { int res = 0 ; Arrays . sort ( ar ) ; 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 = Math . max ( res , count ) ; } return res ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "[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,...
f_gold
ELEMENTS_TO_BE_ADDED_SO_THAT_ALL_ELEMENTS_OF_A_RANGE_ARE_PRESENT_IN_ARRAY_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class ELEMENTS_TO_BE_ADDED_SO_THAT_ALL_ELEMENTS_OF_A_RANGE_ARE_PRESENT_IN_ARRAY_1{ static int f_gold ( int arr [ ] , int n ) { HashSet < Integer > s = new HashSet < > ( ) ; int count = 0 , maxm = Integer . MIN_VALUE , minm = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { s . add ( arr [ i ] ) ; if ( arr [ i ] < minm ) minm = arr [ i ] ; if ( arr [ i ] > maxm ) maxm = arr [ i ] ; } for ( int i = minm ; i <= maxm ; i ++ ) if ( ! s . contains ( i ) ) count ++ ; return count ; }
[]
null
[]
[]
python
code_translation
def f_gold ( diameter , height ) : return 2 * ( diameter + height )
java
[ [ "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", ...
f_gold
FIND_PERIMETER_CYLINDER
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_PERIMETER_CYLINDER{ static int f_gold ( int diameter , int height ) { return 2 * ( diameter + height ) ; }
[]
null
[]
[]
python
code_translation
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 ) ) ;
java
[ [ "[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, ...
f_gold
REMOVE_MINIMUM_ELEMENTS_EITHER_SIDE_2MIN_MAX
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class REMOVE_MINIMUM_ELEMENTS_EITHER_SIDE_2MIN_MAX{ static int f_gold ( int arr [ ] , int n ) { int longest_start = - 1 , longest_end = 0 ; for ( int start = 0 ; start < n ; start ++ ) { int min = Integer . MAX_VALUE , max = Integer . MIN_VALUE ; 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 sys" ]
null
[]
[]
python
code_translation
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 ]
java
[ [ "44", "821223649" ], [ "9", "40" ], [ "19", "4895" ], [ "10", "64" ], [ "78", "10472279279564025" ], [ "94", "23112315624967704576" ], [ "70", "222915410843904" ], [ "81", "44361286907595736" ], [ "81", "443612...
f_gold
COUNT_OFDIFFERENT_WAYS_EXPRESS_N_SUM_1_3_4
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class COUNT_OFDIFFERENT_WAYS_EXPRESS_N_SUM_1_3_4{ static int f_gold ( int n ) { int DP [ ] = new int [ 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
[]
[]
python
code_translation
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
java
[ [ "8", "256" ], [ "39", "549755813888" ], [ "25", "33554432" ], [ "44", "17592186044416" ], [ "72", "4722366482869645213696" ], [ "6", "64" ], [ "72", "4722366482869645213696" ], [ "62", "4611686018427387904" ], [ "4...
f_gold
SUM_BINOMIAL_COEFFICIENTS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class SUM_BINOMIAL_COEFFICIENTS{ static int f_gold ( int n ) { int C [ ] [ ] = new int [ n + 1 ] [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= Math . 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
[]
[]
python
code_translation
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
java
[ [ "51", "36" ], [ "40", "30" ], [ "68", "18" ], [ "7", "8" ], [ "8", "6" ], [ "32", "24" ], [ "93", "60" ], [ "75", "100" ], [ "71", "70" ], [ "15", "20" ] ]
f_gold
FIBONACCI_MODULO_P
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIBONACCI_MODULO_P{ static int f_gold ( int p ) { int first = 1 , second = 1 , number = 2 , next = 1 ; while ( next > 0 ) { next = ( first + second ) % p ; first = second ; second = next ; number ++ ; } return number ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : res = n for j in range ( len ( n ) - 1 , - 1 , - 1 ) : res += n [ j ] return res
java
[ [ "'lSUhEvxcgfI'", "'lSUhEvxcgfIIfgcxvEhUSl'" ], [ "'77329283'", "'7732928338292377'" ], [ "'010111111'", "'010111111111111010'" ], [ "'Stazb'", "'StazbbzatS'" ], [ "'0702'", "'07022070'" ], [ "'01111111'", "'0111111111111110'" ], [ "'a'", ...
f_gold
NTH_EVEN_LENGTH_PALINDROME
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class NTH_EVEN_LENGTH_PALINDROME{ static String f_gold ( String n ) { String res = n ; for ( int j = n . length ( ) - 1 ; j >= 0 ; -- j ) res += n . charAt ( j ) ; return res ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : count = 0 i = 5 while ( n / i >= 1 ) : count += int ( n / i ) i *= 5 return int ( count )
java
[ [ "9", "1" ], [ "43", "9" ], [ "50", "12" ], [ "32", "7" ], [ "37", "8" ], [ "51", "12" ], [ "33", "7" ], [ "49", "10" ], [ "1", "0" ], [ "75", "18" ] ]
f_gold
COUNT_TRAILING_ZEROES_FACTORIAL_NUMBER
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class COUNT_TRAILING_ZEROES_FACTORIAL_NUMBER{ static int f_gold ( int n ) { int count = 0 ; for ( int i = 5 ; n / i >= 1 ; i *= 5 ) count += n / i ; return count ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "[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...
f_gold
NUMBER_OF_PAIRS_IN_AN_ARRAY_HAVING_SUM_EQUAL_TO_PRODUCT
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class NUMBER_OF_PAIRS_IN_AN_ARRAY_HAVING_SUM_EQUAL_TO_PRODUCT{ static 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
[]
[]
python
code_translation
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
java
[ [ "'1787075866'", "True" ], [ "'8'", "True" ], [ "'1110101110111'", "True" ], [ "'6673177113'", "True" ], [ "'7'", "True" ], [ "'000001'", "True" ], [ "'dbxMF'", "True" ], [ "'71733'", "True" ], [ "'01101101100'", ...
f_gold
GIVEN_LARGE_NUMBER_CHECK_SUBSEQUENCE_DIGITS_DIVISIBLE_8
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class GIVEN_LARGE_NUMBER_CHECK_SUBSEQUENCE_DIGITS_DIVISIBLE_8{ static boolean f_gold ( String str ) { int i , j , k , l = str . length ( ) ; int arr [ ] = new int [ l ] ; for ( i = 0 ; i < l ; i ++ ) { for ( j = i ; j < l ; j ++ ) { for ( k = j ; k < l ; k ++ ) { if ( arr [ i ] % 8 == 0 ) return true ; else if ( ( arr [ i ] * 10 + arr [ j ] ) % 8 == 0 && i != j ) return true ; else if ( ( arr [ i ] * 100 + arr [ j ] * 10 + arr [ k ] ) % 8 == 0 && i != j && j != k && i != k ) return true ; } } } return false ; }
[]
null
[]
[]
python
code_translation
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 ) ;
java
[ [ "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", ...
f_gold
TAIL_RECURSION_FIBONACCI
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class TAIL_RECURSION_FIBONACCI{ static int f_gold ( int n , int a , int b ) { if ( n == 0 ) return a ; if ( n == 1 ) return b ; return f_gold ( n - 1 , b , a + b ) ; }
[]
null
[]
[]
python
code_translation
def f_gold ( x , y ) : return ( ( x ^ y ) < 0 ) ;
java
[ [ "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" ],...
f_gold
DETECT_IF_TWO_INTEGERS_HAVE_OPPOSITE_SIGNS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class DETECT_IF_TWO_INTEGERS_HAVE_OPPOSITE_SIGNS{ static boolean f_gold ( int x , int y ) { return ( ( x ^ y ) < 0 ) ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "72", "64" ], [ "75", "69" ], [ "92", "83" ], [ "30", "30" ], [ "45", "41" ], [ "40", "37" ], [ "81", "71" ], [ "17", "17" ], [ "81", "71" ], [ "99", "86" ] ]
f_gold
COUNT_DISTINCT_NON_NEGATIVE_PAIRS_X_Y_SATISFY_INEQUALITY_XX_YY_N_2_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class COUNT_DISTINCT_NON_NEGATIVE_PAIRS_X_Y_SATISFY_INEQUALITY_XX_YY_N_2_1{ static 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
[]
[]
python
code_translation
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
java
[ [ "[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, -...
f_gold
MAXIMUM_HEIGHT_OF_TRIANGULAR_ARRANGEMENT_OF_ARRAY_VALUES
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MAXIMUM_HEIGHT_OF_TRIANGULAR_ARRANGEMENT_OF_ARRAY_VALUES{ static int f_gold ( int [ ] a , int n ) { int result = 1 ; for ( int i = 1 ; i <= n ; ++ i ) { int y = ( i * ( i + 1 ) ) / 2 ; if ( y < n ) result = i ; else break ; } return result ; }
[]
null
[]
[]
python
code_translation
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 ]
java
[ [ "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"...
f_gold
COUNT_BINARY_STRINGS_K_TIMES_APPEARING_ADJACENT_TWO_SET_BITS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class COUNT_BINARY_STRINGS_K_TIMES_APPEARING_ADJACENT_TWO_SET_BITS{ static int f_gold ( int n , int k ) { int dp [ ] [ ] [ ] = new int [ n + 1 ] [ k + 1 ] [ 2 ] ; dp [ 1 ] [ 0 ] [ 0 ] = 1 ; dp [ 1 ] [ 0 ] [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { for ( int j = 0 ; j < i && j < k + 1 ; j ++ ) { 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 >= 0 ) { dp [ i ] [ j ] [ 1 ] += dp [ i - 1 ] [ j - 1 ] [ 1 ] ; } } } return dp [ n ] [ k ] [ 0 ] + dp [ n ] [ k ] [ 1 ] ; }
[]
null
[]
[]
python
code_translation
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 )
java
[ [ "'ncYltuhSxEfG'", "'EcYltuhSxnfG'" ], [ "'26615541616459'", "'16625541616459'" ], [ "'0101'", "'0011'" ], [ "'hK'", "'Kh'" ], [ "'422162103899'", "'122462103899'" ], [ "'0010'", "'0001'" ], [ "'zfcSh'", "'Sfczh'" ], [ "'92'", ...
f_gold
FORM_SMALLEST_NUMBER_USING_ONE_SWAP_OPERATION
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FORM_SMALLEST_NUMBER_USING_ONE_SWAP_OPERATION{ public static String f_gold ( String str ) { char [ ] num = str . toCharArray ( ) ; int n = str . length ( ) ; int [ ] rightMin = new int [ n ] ; rightMin [ n - 1 ] = - 1 ; int right = n - 1 ; for ( int i = n - 2 ; i >= 1 ; i -- ) { if ( num [ i ] > num [ right ] ) 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 ) { char temp ; temp = num [ 0 ] ; num [ 0 ] = num [ small ] ; num [ small ] = temp ; } else { for ( int i = 1 ; i < n ; i ++ ) { if ( rightMin [ i ] != - 1 ) { char temp ; temp = num [ i ] ; num [ i ] = num [ rightMin [ i ] ] ; num [ rightMin [ i ] ] = temp ; break ; } } } return ( new String ( num ) ) ; }
[]
null
[]
[]
python
code_translation
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 ]
java
[ [ "86", "1100087778366101931" ], [ "75", "5527939700884757" ], [ "14", "987" ], [ "5", "13" ], [ "41", "433494437" ], [ "35", "24157817" ], [ "30", "2178309" ], [ "89", "4660046610375530309" ], [ "84", "420196140...
f_gold
COUNT_NUMBER_BINARY_STRINGS_WITHOUT_CONSECUTIVE_1S
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class COUNT_NUMBER_BINARY_STRINGS_WITHOUT_CONSECUTIVE_1S{ static int f_gold ( int n ) { int a [ ] = new int [ n ] ; int b [ ] = new int [ 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
[]
[]
python
code_translation
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 )
java
[ [ "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" ],...
f_gold
CHECK_GIVEN_CIRCLE_LIES_COMPLETELY_INSIDE_RING_FORMED_TWO_CONCENTRIC_CIRCLES
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class CHECK_GIVEN_CIRCLE_LIES_COMPLETELY_INSIDE_RING_FORMED_TWO_CONCENTRIC_CIRCLES{ public static boolean f_gold ( int r , int R , int r1 , int x1 , int y1 ) { int dis = ( int ) Math . sqrt ( x1 * x1 + y1 * y1 ) ; return ( dis - r1 >= R && dis + r1 <= r ) ; }
[ "import math" ]
null
[]
[]
python
code_translation
def f_gold ( a , b ) : return ( a // 2 ) + ( b // 2 ) + ( ( a % 2 + b % 2 ) // 2 )
java
[ [ "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" ] ]
f_gold
COMPUTE_AVERAGE_TWO_NUMBERS_WITHOUT_OVERFLOW_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class COMPUTE_AVERAGE_TWO_NUMBERS_WITHOUT_OVERFLOW_1{ static int f_gold ( int a , int b ) { return ( a / 2 ) + ( b / 2 ) + ( ( a % 2 + b % 2 ) / 2 ) ; }
[]
null
[]
[]
python
code_translation
def f_gold ( side ) : area = side * side return area
java
[ [ "50", "2500" ], [ "64", "4096" ], [ "92", "8464" ], [ "23", "529" ], [ "38", "1444" ], [ "55", "3025" ], [ "67", "4489" ], [ "56", "3136" ], [ "60", "3600" ], [ "90", "8100" ] ]
f_gold
PROGRAM_AREA_SQUARE
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PROGRAM_AREA_SQUARE{ static int f_gold ( int side ) { int area = side * side ; return area ; }
[]
null
[]
[]
python
code_translation
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 ]
java
[ [ "[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, ...
f_gold
MAXIMUM_SUM_PAIRS_SPECIFIC_DIFFERENCE
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MAXIMUM_SUM_PAIRS_SPECIFIC_DIFFERENCE{ static int f_gold ( int arr [ ] , int N , int K ) { Arrays . sort ( arr ) ; int dp [ ] = new int [ 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 ] = Math . max ( dp [ i ] , dp [ i - 2 ] + arr [ i ] + arr [ i - 1 ] ) ; else dp [ i ] = Math . max ( dp [ i ] , arr [ i ] + arr [ i - 1 ] ) ; } } return dp [ N - 1 ] ; }
[]
null
[]
[]
python
code_translation
import math def f_gold ( a ) : area = ( math.pi * a * a ) / 4 return area
java
[ [ "77", "4656.625710783471" ], [ "18", "254.46900494077323" ], [ "83", "5410.607947645021" ], [ "39", "1194.5906065275187" ], [ "68", "3631.6811075498013" ], [ "28", "615.7521601035994" ], [ "71", "3959.192141686537" ], [ "14", ...
f_gold
AREA_OF_THE_CIRCLE_THAT_HAS_A_SQUARE_AND_A_CIRCLE_INSCRIBED_IN_IT
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class AREA_OF_THE_CIRCLE_THAT_HAS_A_SQUARE_AND_A_CIRCLE_INSCRIBED_IN_IT{ static float f_gold ( int a ) { float area = ( float ) ( Math . PI * a * a ) / 4 ; return area ; }
[ "import math" ]
null
[]
[]
python
code_translation
def f_gold ( x ) : return ( x << 1 ) + x + ( x >> 1 )
java
[ [ "58", "203" ], [ "16", "56" ], [ "82", "287" ], [ "33", "115" ], [ "88", "308" ], [ "51", "178" ], [ "81", "283" ], [ "38", "133" ], [ "79", "276" ], [ "89", "311" ] ]
f_gold
MULTIPLY_AN_INTEGER_WITH_3_5
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MULTIPLY_AN_INTEGER_WITH_3_5{ static int f_gold ( int x ) { return ( x << 1 ) + x + ( x >> 1 ) ; }
[]
null
[]
[]
python
code_translation
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 ]
java
[ [ "[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...
f_gold
MAXIMUM_SUM_SUBSEQUENCE_LEAST_K_DISTANT_ELEMENTS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MAXIMUM_SUM_SUBSEQUENCE_LEAST_K_DISTANT_ELEMENTS{ static int f_gold ( int arr [ ] , int N , int k ) { int MS [ ] = new int [ N ] ; MS [ N - 1 ] = arr [ N - 1 ] ; for ( int i = N - 2 ; i >= 0 ; i -- ) { if ( i + k + 1 >= N ) MS [ i ] = Math . max ( arr [ i ] , MS [ i + 1 ] ) ; else MS [ i ] = Math . max ( arr [ i ] + MS [ i + k + 1 ] , MS [ i + 1 ] ) ; } return MS [ 0 ] ; }
[]
null
[]
[]
python
code_translation
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 )
java
[ [ "['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', ...
f_gold
DYNAMIC_PROGRAMMING_SET_28_MINIMUM_INSERTIONS_TO_FORM_A_PALINDROME
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class DYNAMIC_PROGRAMMING_SET_28_MINIMUM_INSERTIONS_TO_FORM_A_PALINDROME{ static int f_gold ( char str [ ] , int l , int h ) { if ( l > h ) return Integer . MAX_VALUE ; 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 ) : ( Integer . min ( f_gold ( str , l , h - 1 ) , f_gold ( str , l + 1 , h ) ) + 1 ) ; }
[ "import sys" ]
null
[]
[]
python
code_translation
def f_gold ( n ) : return ( int ) ( 0.6172 * ( pow ( 10 , n ) - 1 ) - 0.55 * n )
java
[ [ "18", "617200000000000000" ], [ "81", "617199999999999917125494104322701119480482791516235510304887841509964568007278592" ], [ "77", "61720000000000002223209770321473706212913932736699901607714125885487833939968" ], [ "84", "617199999999999978627872438760098151064610958...
f_gold
SUM_SERIES_555555_N_TERMS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class SUM_SERIES_555555_N_TERMS{ static int f_gold ( int n ) { return ( int ) ( 0.6172 * ( Math . pow ( 10 , n ) - 1 ) - 0.55 * n ) ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : return ( n * ( n + 1 ) / 2 ) * ( 1 << ( n - 1 ) )
java
[ [ "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" ...
f_gold
SUM_SUBSETS_SET_FORMED_FIRST_N_NATURAL_NUMBERS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class SUM_SUBSETS_SET_FORMED_FIRST_N_NATURAL_NUMBERS{ static long f_gold ( int n ) { return ( n * ( n + 1 ) / 2 ) * ( 1 << ( n - 1 ) ) ; }
[]
null
[]
[]
python
code_translation
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 )
java
[ [ "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" ] ]
f_gold
PROGRAM_TO_FIND_REMAINDER_WITHOUT_USING_MODULO_OR_OPERATOR_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PROGRAM_TO_FIND_REMAINDER_WITHOUT_USING_MODULO_OR_OPERATOR_1{ static int f_gold ( int num , int divisor ) { if ( divisor == 0 ) { System . out . println ( "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
[]
[]
python
code_translation
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
java
[ [ "62", "True" ], [ "13", "False" ], [ "29", "False" ], [ "72", "True" ], [ "30", "True" ], [ "20", "True" ], [ "10", "True" ], [ "47", "False" ], [ "91", "True" ], [ "52", "True" ] ]
f_gold
COMPOSITE_NUMBER
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class COMPOSITE_NUMBER{ static boolean f_gold ( int n ) { if ( n <= 1 ) System . out . println ( "False" ) ; if ( n <= 3 ) System . out . println ( "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
[]
[]
python
code_translation
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
java
[ [ "[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, ...
f_gold
PROGRAM_PAGE_REPLACEMENT_ALGORITHMS_SET_2_FIFO
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PROGRAM_PAGE_REPLACEMENT_ALGORITHMS_SET_2_FIFO{ static int f_gold ( int pages [ ] , int n , int capacity ) { HashSet < Integer > s = new HashSet < > ( capacity ) ; Queue < Integer > indexes = new LinkedList < > ( ) ; int page_faults = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . size ( ) < capacity ) { if ( ! s . contains ( pages [ i ] ) ) { s . add ( pages [ i ] ) ; page_faults ++ ; indexes . add ( pages [ i ] ) ; } } else { if ( ! s . contains ( pages [ i ] ) ) { int val = indexes . peek ( ) ; indexes . poll ( ) ; s . remove ( val ) ; s . add ( pages [ i ] ) ; indexes . add ( pages [ i ] ) ; page_faults ++ ; } } } return page_faults ; }
[ "from queue import Queue" ]
null
[]
[]
python
code_translation
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 )
java
[ [ "[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...
f_gold
MAXIMUM_TRIPLET_SUM_ARRAY_2
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MAXIMUM_TRIPLET_SUM_ARRAY_2{ static int f_gold ( int arr [ ] , int n ) { int maxA = - 100000000 , maxB = - 100000000 ; int maxC = - 100000000 ; 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
[]
[]
python
code_translation
import math def f_gold ( side ) : return ( 2 * ( 1 + ( math.sqrt ( 2 ) ) ) * side * side )
java
[ [ "5859.798616323926", "165794860.15449765" ], [ "-6381.210375893524", "196612808.27272156" ], [ "2442.246292006922", "28799476.852711495" ], [ "-9624.81536339737", "447291345.3087225" ], [ "8679.436805247444", "363738081.5089271" ], [ "-2682.324540108...
f_gold
PROGRAM_CALCULATE_AREA_OCTAGON
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PROGRAM_CALCULATE_AREA_OCTAGON{ static double f_gold ( double side ) { return ( float ) ( 2 * ( 1 + Math . sqrt ( 2 ) ) * side * side ) ; }
[ "import math" ]
null
[]
[]
python
code_translation
import math def f_gold ( side ) : return ( ( side * side * side ) * ( math.sqrt ( 2 ) / 3 ) )
java
[ [ "3355.322051344013", "17807230335.375374" ], [ "-891.0551553192736", "-333508958.9649689" ], [ "8242.699647177868", "263998930936.71603" ], [ "-9259.146104439229", "-374202387762.81836" ], [ "7712.806145993083", "216287285897.3415" ], [ "-4998.858862...
f_gold
PROGRAM_CALCULATE_VOLUME_OCTAHEDRON
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PROGRAM_CALCULATE_VOLUME_OCTAHEDRON{ static double f_gold ( double side ) { return ( ( side * side * side ) * ( Math . sqrt ( 2 ) / 3 ) ) ; }
[ "import math" ]
null
[]
[]
python
code_translation
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 ) )
java
[ [ "[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",...
f_gold
SEARCH_INSERT_AND_DELETE_IN_A_SORTED_ARRAY
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class SEARCH_INSERT_AND_DELETE_IN_A_SORTED_ARRAY{ static 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
[]
[]
python
code_translation
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 ]
java
[ [ "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" ], [ ...
f_gold
MAXIMUM_NUMBER_SEGMENTS_LENGTHS_B_C
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MAXIMUM_NUMBER_SEGMENTS_LENGTHS_B_C{ static int f_gold ( int n , int a , int b , int c ) { int dp [ ] = new int [ n + 10 ] ; Arrays . fill ( dp , - 1 ) ; dp [ 0 ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( dp [ i ] != - 1 ) { if ( i + a <= n ) dp [ i + a ] = Math . max ( dp [ i ] + 1 , dp [ i + a ] ) ; if ( i + b <= n ) dp [ i + b ] = Math . max ( dp [ i ] + 1 , dp [ i + b ] ) ; if ( i + c <= n ) dp [ i + c ] = Math . max ( dp [ i ] + 1 , dp [ i + c ] ) ; } } return dp [ n ] ; }
[]
null
[]
[]
python
code_translation
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 ] ;
java
[ [ "37", "3831006429" ], [ "82", "3108406708580377597810" ], [ "87", "65431225571591367370292" ], [ "80", "918838005896863447985" ], [ "92", "1377311813149359327046015" ], [ "58", "1383410902447554" ], [ "98", "53324762928098149064722658...
f_gold
COUNT_NUMBER_OF_WAYS_TO_COVER_A_DISTANCE_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class COUNT_NUMBER_OF_WAYS_TO_COVER_A_DISTANCE_1{ static int f_gold ( int dist ) { int [ ] count = new int [ 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
[]
[]
python
code_translation
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
java
[ [ "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" ...
f_gold
MIDDLE_OF_THREE_USING_MINIMUM_COMPARISONS_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MIDDLE_OF_THREE_USING_MINIMUM_COMPARISONS_1{ public static 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
[]
[]
python
code_translation
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]
java
[ [ "'YCtLQtHLwr'", "8" ], [ "'47713514383248'", "7" ], [ "'0100101001111'", "3" ], [ "'XfdIYVn'", "7" ], [ "'45499225407'", "5" ], [ "'000100111001'", "2" ], [ "'ZoUQhQwoap'", "6" ], [ "'18579027952'", "7" ], [ "'0000...
f_gold
MINIMUM_STEPS_TO_DELETE_A_STRING_AFTER_REPEATED_DELETION_OF_PALINDROME_SUBSTRINGS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MINIMUM_STEPS_TO_DELETE_A_STRING_AFTER_REPEATED_DELETION_OF_PALINDROME_SUBSTRINGS{ static int f_gold ( String str ) { int N = str . length ( ) ; int [ ] [ ] dp = new int [ 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 . charAt ( i ) == str . charAt ( i + 1 ) ) dp [ i ] [ j ] = Math . min ( 1 + dp [ i + 2 ] [ j ] , dp [ i ] [ j ] ) ; for ( int K = i + 2 ; K <= j ; K ++ ) if ( str . charAt ( i ) == str . charAt ( K ) ) dp [ i ] [ j ] = Math . min ( dp [ i + 1 ] [ K - 1 ] + dp [ K + 1 ] [ j ] , dp [ i ] [ j ] ) ; } } } return dp [ 0 ] [ N - 1 ] ; }
[]
null
[]
[]
python
code_translation
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 ) ) ) ;
java
[ [ "[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, -...
f_gold
DYNAMIC_PROGRAMMING_HIGH_EFFORT_VS_LOW_EFFORT_TASKS_PROBLEM
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class DYNAMIC_PROGRAMMING_HIGH_EFFORT_VS_LOW_EFFORT_TASKS_PROBLEM{ static int f_gold ( int high [ ] , int low [ ] , int n ) { if ( n <= 0 ) return 0 ; return Math . max ( high [ n - 1 ] + f_gold ( high , low , ( n - 2 ) ) , low [ n - 1 ] + f_gold ( high , low , ( n - 1 ) ) ) ; }
[]
null
[]
[]
python
code_translation
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 ) ;
java
[ [ "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"...
f_gold
FIND_SUM_MODULO_K_FIRST_N_NATURAL_NUMBER_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_SUM_MODULO_K_FIRST_N_NATURAL_NUMBER_1{ static 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
[]
[]
python
code_translation
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
java
[ [ "45", "28.832815729997478" ], [ "80", "37.77708763999664" ], [ "54", "29.393876913398138" ], [ "48", "29.712812921102035" ], [ "83", "36.4417343165772" ], [ "68", "32.984845004941285" ], [ "32", "24.62741699796952" ], [ "20", ...
f_gold
MINIMUM_PERIMETER_N_BLOCKS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MINIMUM_PERIMETER_N_BLOCKS{ public static long f_gold ( int n ) { int l = ( int ) Math . sqrt ( n ) ; int sq = l * l ; if ( sq == n ) return l * 4 ; else { long row = n / l ; long perimeter = 2 * ( l + row ) ; if ( n % l != 0 ) perimeter += 2 ; return perimeter ; } }
[ "import math" ]
null
[]
[]
python
code_translation
def f_gold ( n ) : return n & ( n - 1 )
java
[ [ "9", "8" ], [ "54", "52" ], [ "60", "56" ], [ "32", "0" ], [ "41", "40" ], [ "64", "0" ], [ "4", "0" ], [ "51", "50" ], [ "57", "56" ], [ "92", "88" ] ]
f_gold
TURN_OFF_THE_RIGHTMOST_SET_BIT
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class TURN_OFF_THE_RIGHTMOST_SET_BIT{ static int f_gold ( int n ) { return n & ( n - 1 ) ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "'ORXMflacQFBv'", "-1" ], [ "'39977638567848'", "0" ], [ "'011110011011'", "0" ], [ "'fYjfNy'", "0" ], [ "'222280492'", "0" ], [ "'11'", "0" ], [ "'UjntBg'", "-1" ], [ "'6866190138212'", "0" ], [ "'0000'", "0" ...
f_gold
FIND_REPEATED_CHARACTER_PRESENT_FIRST_STRING
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_REPEATED_CHARACTER_PRESENT_FIRST_STRING{ static int f_gold ( String s ) { int p = - 1 , i , j ; for ( i = 0 ; i < s . length ( ) ; i ++ ) { for ( j = i + 1 ; j < s . length ( ) ; j ++ ) { if ( s . charAt ( i ) == s . charAt ( j ) ) { p = i ; break ; } } if ( p != - 1 ) break ; } return p ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "[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" ...
f_gold
FIND_THE_MAXIMUM_SUBARRAY_XOR_IN_A_GIVEN_ARRAY
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_THE_MAXIMUM_SUBARRAY_XOR_IN_A_GIVEN_ARRAY{ static int f_gold ( int arr [ ] , int n ) { int ans = Integer . MIN_VALUE ; 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 = Math . max ( ans , curr_xor ) ; } } return ans ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "'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 ...
f_gold
STRING_CONTAINING_FIRST_LETTER_EVERY_WORD_GIVEN_STRING_SPACES
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class STRING_CONTAINING_FIRST_LETTER_EVERY_WORD_GIVEN_STRING_SPACES{ static String f_gold ( String str ) { String result = "" ; boolean v = true ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == ' ' ) { v = true ; } else if ( str . charAt ( i ) != ' ' && v == true ) { result += ( str . charAt ( i ) ) ; v = false ; } } return result ; }
[]
null
[]
[]
python
code_translation
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 )
java
[ [ "[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", "...
f_gold
MAXIMUM_POSSIBLE_DIFFERENCE_TWO_SUBSETS_ARRAY
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MAXIMUM_POSSIBLE_DIFFERENCE_TWO_SUBSETS_ARRAY{ static int f_gold ( int [ ] arr , int n ) { int SubsetSum_1 = 0 , SubsetSum_2 = 0 ; for ( int i = 0 ; i <= n - 1 ; i ++ ) { boolean 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 Math . abs ( SubsetSum_1 - SubsetSum_2 ) ; }
[]
null
[]
[]
python
code_translation
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 ]
java
[ [ "50", "57" ], [ "83", "93" ], [ "18", "19" ], [ "24", "27" ], [ "31", "32" ], [ "38", "41" ], [ "94", "104" ], [ "24", "27" ], [ "13", "13" ], [ "53", "57" ] ]
f_gold
RECURSIVELY_BREAK_NUMBER_3_PARTS_GET_MAXIMUM_SUM_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class RECURSIVELY_BREAK_NUMBER_3_PARTS_GET_MAXIMUM_SUM_1{ static int f_gold ( int n ) { int dp [ ] = new int [ n + 1 ] ; dp [ 0 ] = 0 ; dp [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) dp [ i ] = Math . max ( dp [ i / 2 ] + dp [ i / 3 ] + dp [ i / 4 ] , i ) ; return dp [ n ] ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "[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...
f_gold
MINIMUM_COST_FOR_ACQUIRING_ALL_COINS_WITH_K_EXTRA_COINS_ALLOWED_WITH_EVERY_COIN
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MINIMUM_COST_FOR_ACQUIRING_ALL_COINS_WITH_K_EXTRA_COINS_ALLOWED_WITH_EVERY_COIN{ static int f_gold ( int coin [ ] , int n , int k ) { Arrays . sort ( coin ) ; int coins_needed = ( int ) Math . ceil ( 1.0 * n / ( k + 1 ) ) ; int ans = 0 ; for ( int i = 0 ; i <= coins_needed - 1 ; i ++ ) ans += coin [ i ] ; return ans ; }
[ "import math" ]
null
[]
[]
python
code_translation
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 ;
java
[ [ "1", "1" ], [ "92", "124155792775" ], [ "29", "2513" ], [ "52", "1618192" ], [ "55", "3761840" ], [ "13", "28" ], [ "83", "9882257736" ], [ "83", "9882257736" ], [ "10", "12" ], [ "67", "109870576" ...
f_gold
PADOVAN_SEQUENCE
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PADOVAN_SEQUENCE{ static int f_gold ( int n ) { int pPrevPrev = 1 , pPrev = 1 , pCurr = 1 , pNext = 1 ; for ( int i = 3 ; i <= n ; i ++ ) { pNext = pPrevPrev + pPrev ; pPrevPrev = pPrev ; pPrev = pCurr ; pCurr = pNext ; } return pNext ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "[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...
f_gold
CEILING_IN_A_SORTED_ARRAY
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class CEILING_IN_A_SORTED_ARRAY{ static int f_gold ( int arr [ ] , int low , int high , int x ) { int i ; if ( x <= arr [ low ] ) return low ; for ( i = low ; i < high ; i ++ ) { if ( arr [ i ] == x ) return i ; if ( arr [ i ] < x && arr [ i + 1 ] >= x ) return i + 1 ; } return - 1 ; }
[]
null
[]
[]
python
code_translation
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 ] )
java
[ [ "[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,...
f_gold
MINIMUM_SUM_SUBSEQUENCE_LEAST_ONE_EVERY_FOUR_CONSECUTIVE_ELEMENTS_PICKED_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MINIMUM_SUM_SUBSEQUENCE_LEAST_ONE_EVERY_FOUR_CONSECUTIVE_ELEMENTS_PICKED_1{ static int f_gold ( int ar [ ] , int n ) { if ( n <= 4 ) return Arrays . stream ( ar ) . min ( ) . getAsInt ( ) ; int [ ] sum = new int [ n ] ; sum [ 0 ] = ar [ 0 ] ; sum [ 1 ] = ar [ 1 ] ; sum [ 2 ] = ar [ 2 ] ; sum [ 3 ] = ar [ 3 ] ; for ( int i = 4 ; i < n ; i ++ ) sum [ i ] = ar [ i ] + Arrays . stream ( Arrays . copyOfRange ( sum , i - 4 , i ) ) . min ( ) . getAsInt ( ) ; return Arrays . stream ( Arrays . copyOfRange ( sum , n - 4 , n ) ) . min ( ) . getAsInt ( ) ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "[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, ...
f_gold
COUNT_PAIRS_TWO_SORTED_ARRAYS_WHOSE_SUM_EQUAL_GIVEN_VALUE_X
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class COUNT_PAIRS_TWO_SORTED_ARRAYS_WHOSE_SUM_EQUAL_GIVEN_VALUE_X{ static int f_gold ( int [ ] arr1 , int [ ] arr2 , int m , int n , int x ) { int count = 0 ; for ( int i = 0 ; i < m ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) if ( ( arr1 [ i ] + arr2 [ j ] ) == x ) count ++ ; return count ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "67", "True" ], [ "77", "True" ], [ "35", "False" ], [ "79", "False" ], [ "45", "True" ], [ "22", "True" ], [ "68", "False" ], [ "17", "False" ], [ "5", "True" ], [ "85", "False" ] ]
f_gold
CHECK_IF_A_NUMBER_IS_JUMBLED_OR_NOT
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class CHECK_IF_A_NUMBER_IS_JUMBLED_OR_NOT{ static boolean f_gold ( int num ) { if ( num / 10 == 0 ) return true ; while ( num != 0 ) { if ( num / 10 == 0 ) return true ; int digit1 = num % 10 ; int digit2 = ( num / 10 ) % 10 ; if ( Math . abs ( digit2 - digit1 ) > 1 ) return false ; num = num / 10 ; } return true ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "'qnQxjoRx'", "'x'" ], [ "'27473733400077'", "'7733007'" ], [ "'000010111111'", "'0000111111'" ], [ "'TNVwgrWSLu'", "''" ], [ "'9537'", "''" ], [ "'1100'", "'10'" ], [ "'lYcoiQfzN'", "''" ], [ "'52'", "''" ], [ "'0...
f_gold
LONGEST_REPEATED_SUBSEQUENCE_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class LONGEST_REPEATED_SUBSEQUENCE_1{ static String f_gold ( String str ) { int n = str . length ( ) ; int [ ] [ ] dp = new int [ 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 . charAt ( i - 1 ) == str . charAt ( j - 1 ) && i != j ) dp [ i ] [ j ] = 1 + dp [ i - 1 ] [ j - 1 ] ; else dp [ i ] [ j ] = Math . max ( dp [ i ] [ j - 1 ] , dp [ i - 1 ] [ j ] ) ; String res = "" ; int i = n , j = n ; while ( i > 0 && j > 0 ) { if ( dp [ i ] [ j ] == dp [ i - 1 ] [ j - 1 ] + 1 ) { res = res + str . charAt ( i - 1 ) ; i -- ; j -- ; } else if ( dp [ i ] [ j ] == dp [ i - 1 ] [ j ] ) i -- ; else j -- ; } String reverse = "" ; for ( int k = res . length ( ) - 1 ; k >= 0 ; k -- ) { reverse = reverse + res . charAt ( k ) ; } return reverse ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "34", "66" ], [ "49", "104" ], [ "41", "83" ], [ "17", "28" ], [ "67", "151" ], [ "38", "76" ], [ "59", "128" ], [ "64", "144" ], [ "61", "135" ], [ "58", "127" ] ]
f_gold
NUMBER_UNIQUE_RECTANGLES_FORMED_USING_N_UNIT_SQUARES
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class NUMBER_UNIQUE_RECTANGLES_FORMED_USING_N_UNIT_SQUARES{ static int f_gold ( int n ) { int ans = 0 ; for ( int length = 1 ; length <= Math . sqrt ( n ) ; ++ length ) for ( int height = length ; height * length <= n ; ++ height ) ans ++ ; return ans ; }
[ "import math" ]
null
[]
[]
python
code_translation
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 ;
java
[ [ "[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,...
f_gold
POSITION_ELEMENT_STABLE_SORT
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class POSITION_ELEMENT_STABLE_SORT{ static int f_gold ( int arr [ ] , int n , int idx ) { int result = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < arr [ idx ] ) result ++ ; if ( arr [ i ] == arr [ idx ] && i < idx ) result ++ ; } return result ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "'Qaq'", "0" ], [ "'9400761825850'", "16" ], [ "'0011001111'", "10" ], [ "'lasWqrLRq'", "11" ], [ "'5662'", "1" ], [ "'110'", "1" ], [ "' tOYKf'", "6" ], [ "'6536991235305'", "11" ], [ "'11111'", "0" ], [ ...
f_gold
NUMBER_SUBSTRINGS_DIVISIBLE_4_STRING_INTEGERS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class NUMBER_SUBSTRINGS_DIVISIBLE_4_STRING_INTEGERS{ static int f_gold ( String s ) { int n = s . length ( ) ; int count = 0 ; for ( int i = 0 ; i < n ; ++ i ) if ( s . charAt ( i ) == '4' || s . charAt ( i ) == '8' || s . charAt ( i ) == '0' ) count ++ ; for ( int i = 0 ; i < n - 1 ; ++ i ) { int h = ( s . charAt ( i ) - '0' ) * 10 + ( s . charAt ( i + 1 ) - '0' ) ; if ( h % 4 == 0 ) count = count + i + 1 ; } return count ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : x = n y = 1 e = 0.000001 while ( x - y > e ) : x = ( x + y ) / 2 y = n / x return x
java
[ [ "1763.655093333857", "41.99589376968351" ], [ "-3544.737136289062", "-3544.737136289062" ], [ "7893.209433000695", "88.84373605423394" ], [ "-3008.0331952533734", "-3008.0331952533734" ], [ "6155.190186637041", "78.45502015008492" ], [ "-5799.7514673...
f_gold
SQUARE_ROOT_OF_A_PERFECT_SQUARE
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class SQUARE_ROOT_OF_A_PERFECT_SQUARE{ static float f_gold ( float n ) { float x = n ; float y = 1 ; double e = 0.000001 ; while ( x - y > e ) { x = ( x + y ) / 2 ; y = n / x ; } return x ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : return ( ( n << 3 ) - n )
java
[ [ "41", "287" ], [ "42", "294" ], [ "62", "434" ], [ "4", "28" ], [ "31", "217" ], [ "75", "525" ], [ "5", "35" ], [ "75", "525" ], [ "85", "595" ], [ "19", "133" ] ]
f_gold
EFFICIENT_WAY_TO_MULTIPLY_WITH_7
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class EFFICIENT_WAY_TO_MULTIPLY_WITH_7{ static int f_gold ( int n ) { return ( ( n << 3 ) - n ) ; }
[]
null
[]
[]
python
code_translation
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 ;
java
[ [ "23", "1352078" ], [ "41", "269128937220" ], [ "69", "56093138908331422716" ], [ "56", "7648690600760440" ], [ "71", "221256270138418389602" ], [ "38", "35345263800" ], [ "26", "10400600" ], [ "52", "495918532948104" ], ...
f_gold
MAXIMUM_BINOMIAL_COEFFICIENT_TERM_VALUE
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MAXIMUM_BINOMIAL_COEFFICIENT_TERM_VALUE{ static int f_gold ( int n ) { int [ ] [ ] C = new int [ n + 1 ] [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= Math . 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 maxvalue = 0 ; for ( int i = 0 ; i <= n ; i ++ ) maxvalue = Math . max ( maxvalue , C [ n ] [ i ] ) ; return maxvalue ; }
[]
null
[]
[]
python
code_translation
def f_gold ( l , b , h ) : return ( ( l * b * h ) / 2 )
java
[ [ "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...
f_gold
PROGRAM_TO_FIND_THE_VOLUME_OF_A_TRIANGULAR_PRISM
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PROGRAM_TO_FIND_THE_VOLUME_OF_A_TRIANGULAR_PRISM{ static float f_gold ( float l , float b , float h ) { float volume = ( l * b * h ) / 2 ; return volume ; }
[]
null
[]
[]
python
code_translation
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)
java
[ [ "[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" ...
f_gold
MINIMUM_TIME_TO_FINISH_TASKS_WITHOUT_SKIPPING_TWO_CONSECUTIVE
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MINIMUM_TIME_TO_FINISH_TASKS_WITHOUT_SKIPPING_TWO_CONSECUTIVE{ static int f_gold ( int arr [ ] , int n ) { if ( n <= 0 ) return 0 ; int incl = arr [ 0 ] ; int excl = 0 ; for ( int i = 1 ; i < n ; i ++ ) { int incl_new = arr [ i ] + Math . min ( excl , incl ) ; int excl_new = incl ; incl = incl_new ; excl = excl_new ; } return Math . min ( incl , excl ) ; }
[]
null
[]
[]
python
code_translation
import math def f_gold ( side ) : return ( 2 * ( math.sqrt ( 3 ) ) * ( side * side ) )
java
[ [ "1449.255716877097", "7275798.574924052" ], [ "-8772.104874265995", "266562009.34357828" ], [ "2948.419328234334", "30114046.875937637" ], [ "-1184.220109553511", "4857977.358664159" ], [ "7422.825800698956", "190866258.51879707" ], [ "-5808.28000617...
f_gold
PROGRAM_FOR_SURFACE_AREA_OF_OCTAHEDRON
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PROGRAM_FOR_SURFACE_AREA_OF_OCTAHEDRON{ static double f_gold ( double side ) { return ( 2 * ( Math . sqrt ( 3 ) ) * ( side * side ) ) ; }
[ "import math" ]
null
[]
[]
python
code_translation
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
java
[ [ "'gILrzLimS', 'm'", "True" ], [ "'307471222', '2'", "True" ], [ "'110', '0'", "True" ], [ "'GcAB', 'v'", "True" ], [ "'113', '3'", "True" ], [ "'011110010', '0'", "False" ], [ "'wcwob', 'w'", "False" ], [ "'74571582216153', '1...
f_gold
CHECK_OCCURRENCES_CHARACTER_APPEAR_TOGETHER
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class CHECK_OCCURRENCES_CHARACTER_APPEAR_TOGETHER{ static boolean f_gold ( String s , char c ) { boolean oneSeen = false ; int i = 0 , n = s . length ( ) ; while ( i < n ) { if ( s . charAt ( i ) == c ) { if ( oneSeen == true ) return false ; while ( i < n && s . charAt ( i ) == c ) i ++ ; oneSeen = true ; } else i ++ ; } return true ; }
[]
null
[]
[]
python
code_translation
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 ) ;
java
[ [ "[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, ...
f_gold
MINIMUM_DIFFERENCE_BETWEEN_GROUPS_OF_SIZE_TWO
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MINIMUM_DIFFERENCE_BETWEEN_GROUPS_OF_SIZE_TWO{ static long f_gold ( long a [ ] , int n ) { Arrays . sort ( a ) ; int i , j ; Vector < Long > s = new Vector < > ( ) ; for ( i = 0 , j = n - 1 ; i < j ; i ++ , j -- ) s . add ( ( a [ i ] + a [ j ] ) ) ; long mini = Collections . min ( s ) ; long maxi = Collections . max ( s ) ; return Math . abs ( maxi - mini ) ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "[[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...
f_gold
PROGRAM_TO_CHECK_IF_A_MATRIX_IS_SYMMETRIC
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PROGRAM_TO_CHECK_IF_A_MATRIX_IS_SYMMETRIC{ static boolean f_gold ( int mat [ ] [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) if ( mat [ i ] [ j ] != mat [ j ] [ i ] ) return false ; return true ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "95", "95" ], [ "48", "3" ], [ "3", "3" ], [ "10", "10" ], [ "82", "82" ], [ "1", "1" ], [ "77", "77" ], [ "99", "11" ], [ "23", "23" ], [ "61", "61" ] ]
f_gold
FIND_MINIMUM_NUMBER_DIVIDED_MAKE_NUMBER_PERFECT_SQUARE
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_MINIMUM_NUMBER_DIVIDED_MAKE_NUMBER_PERFECT_SQUARE{ static int f_gold ( int n ) { int count = 0 , ans = 1 ; while ( n % 2 == 0 ) { count ++ ; n /= 2 ; } if ( count % 2 == 1 ) ans *= 2 ; for ( int i = 3 ; i <= Math . sqrt ( n ) ; i += 2 ) { count = 0 ; while ( n % i == 0 ) { count ++ ; n /= i ; } if ( count % 2 == 1 ) ans *= i ; } if ( n > 2 ) ans *= n ; return ans ; }
[ "import math" ]
null
[]
[]
python
code_translation
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
java
[ [ "[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"...
f_gold
FIND_SUM_NON_REPEATING_DISTINCT_ELEMENTS_ARRAY
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_SUM_NON_REPEATING_DISTINCT_ELEMENTS_ARRAY{ static int f_gold ( int arr [ ] , int n ) { int sum = 0 ; HashSet < Integer > s = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! s . contains ( arr [ i ] ) ) { sum += arr [ i ] ; s . add ( arr [ i ] ) ; } } return sum ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : return 1 if ( n == 1 or n == 0 ) else n * f_gold ( n - 1 ) ;
java
[ [ "84", "3314240134565353266999387579130131288000666286242049487118846032383059131291716864129885722968716753156177920000000000000000000" ], [ "41", "33452526613163807108170062053440751665152000000000" ], [ "5", "120" ], [ "38", "523022617466601111760007224100074291200000...
f_gold
C_PROGRAM_FACTORIAL_NUMBER
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class C_PROGRAM_FACTORIAL_NUMBER{ static int f_gold ( int n ) { if ( n == 0 ) return 1 ; return n * f_gold ( n - 1 ) ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "'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'", ...
f_gold
FORM_MINIMUM_NUMBER_FROM_GIVEN_SEQUENCE_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FORM_MINIMUM_NUMBER_FROM_GIVEN_SEQUENCE_1{ static String f_gold ( String seq ) { int n = seq . length ( ) ; if ( n >= 9 ) return "-1" ; char result [ ] = new char [ n + 1 ] ; int count = 1 ; for ( int i = 0 ; i <= n ; i ++ ) { if ( i == n || seq . charAt ( i ) == 'I' ) { for ( int j = i - 1 ; j >= - 1 ; j -- ) { result [ j + 1 ] = ( char ) ( ( int ) '0' + count ++ ) ; if ( j >= 0 && seq . charAt ( j ) == 'I' ) break ; } } } return new String ( result ) ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "[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, ...
f_gold
FIND_MAXIMUM_SUM_POSSIBLE_EQUAL_SUM_THREE_STACKS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_MAXIMUM_SUM_POSSIBLE_EQUAL_SUM_THREE_STACKS{ public static int f_gold ( int stack1 [ ] , int stack2 [ ] , int stack3 [ ] , int n1 , int n2 , int n3 ) { int sum1 = 0 , sum2 = 0 , sum3 = 0 ; for ( int i = 0 ; i < n1 ; i ++ ) sum1 += stack1 [ i ] ; for ( int i = 0 ; i < n2 ; i ++ ) sum2 += stack2 [ i ] ; for ( int i = 0 ; i < n3 ; i ++ ) sum3 += stack3 [ i ] ; int top1 = 0 , top2 = 0 , top3 = 0 ; int ans = 0 ; while ( true ) { if ( top1 == n1 || top2 == n2 || top3 == n3 ) return 0 ; if ( sum1 == sum2 && sum2 == sum3 ) return sum1 ; if ( sum1 >= sum2 && sum1 >= sum3 ) sum1 -= stack1 [ top1 ++ ] ; else if ( sum2 >= sum3 && sum2 >= sum3 ) sum2 -= stack2 [ top2 ++ ] ; else if ( sum3 >= sum2 && sum3 >= sum1 ) sum3 -= stack3 [ top3 ++ ] ; } }
[]
null
[]
[]
python
code_translation
def f_gold ( N , K ) : ans = 0 ; for i in range ( 1 , N + 1 ) : ans += ( i % K ) ; return ans ;
java
[ [ "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"...
f_gold
FIND_SUM_MODULO_K_FIRST_N_NATURAL_NUMBER
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_SUM_MODULO_K_FIRST_N_NATURAL_NUMBER{ static int f_gold ( int N , int K ) { int ans = 0 ; for ( int i = 1 ; i <= N ; i ++ ) ans += ( i % K ) ; return ans ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "'cI'", "-1" ], [ "'76478'", "2" ], [ "'1'", "-1" ], [ "'tr'", "-1" ], [ "'10'", "-1" ], [ "'01'", "-1" ], [ "'Rmhzp'", "-1" ], [ "'5784080133917'", "10" ], [ "'1100'", "0" ], [ "'OK'", "-1" ] ]
f_gold
MAXIMUM_NUMBER_CHARACTERS_TWO_CHARACTER_STRING
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MAXIMUM_NUMBER_CHARACTERS_TWO_CHARACTER_STRING{ static int f_gold ( String str ) { int n = str . length ( ) ; int res = - 1 ; for ( int i = 0 ; i < n - 1 ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( str . charAt ( i ) == str . charAt ( j ) ) res = Math . max ( res , Math . abs ( j - i - 1 ) ) ; return res ; }
[]
null
[]
[]
python
code_translation
from math import floor def f_gold ( a , b ) : return floor ( ( a + b ) / 2 )
java
[ [ "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" ] ]
f_gold
COMPUTE_AVERAGE_TWO_NUMBERS_WITHOUT_OVERFLOW
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class COMPUTE_AVERAGE_TWO_NUMBERS_WITHOUT_OVERFLOW{ static int f_gold ( int a , int b ) { return ( a + b ) / 2 ; }
[ "from math import floor" ]
null
[]
[]
python
code_translation
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
java
[ [ "'()'", "0" ], [ "'))(('", "4" ], [ "'())'", "-1" ], [ "'(()'", "-1" ], [ "'(()()())'", "0" ], [ "'))())(()(())'", "-1" ], [ "'))(())(('", "8" ], [ "'49'", "3" ], [ "'00001111'", "36" ], [ "'KDahByG '",...
f_gold
COST_BALANCE_PARANTHESES
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class COST_BALANCE_PARANTHESES{ static int f_gold ( String s ) { if ( s . length ( ) == 0 ) System . out . println ( 0 ) ; int ans = 0 ; int o = 0 , c = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '(' ) o ++ ; if ( s . charAt ( i ) == ')' ) c ++ ; } if ( o != c ) return - 1 ; int [ ] a = new int [ s . length ( ) ] ; if ( s . charAt ( 0 ) == '(' ) a [ 0 ] = 1 ; else a [ 0 ] = - 1 ; if ( a [ 0 ] < 0 ) ans += Math . abs ( a [ 0 ] ) ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '(' ) a [ i ] = a [ i - 1 ] + 1 ; else a [ i ] = a [ i - 1 ] - 1 ; if ( a [ i ] < 0 ) ans += Math . abs ( a [ i ] ) ; } return ans ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "[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,...
f_gold
PROGRAM_FIND_SMALLEST_DIFFERENCE_ANGLES_TWO_PARTS_GIVEN_CIRCLE
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PROGRAM_FIND_SMALLEST_DIFFERENCE_ANGLES_TWO_PARTS_GIVEN_CIRCLE{ public static int f_gold ( int arr [ ] , int n ) { int l = 0 , sum = 0 , ans = 360 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; while ( sum >= 180 ) { ans = Math . min ( ans , 2 * Math . abs ( 180 - sum ) ) ; sum -= arr [ l ] ; l ++ ; } ans = Math . min ( ans , 2 * Math . abs ( 180 - sum ) ) ; } return ans ; }
[]
null
[]
[]
python
code_translation
def f_gold ( x ) : return ( x and ( not ( x & ( x - 1 ) ) ) )
java
[ [ "1", "True" ], [ "2", "True" ], [ "8", "True" ], [ "1024", "True" ], [ "24", "False" ], [ "7", "False" ], [ "46", "False" ], [ "61", "False" ], [ "73", "False" ], [ "66", "False" ] ]
f_gold
WRITE_ONE_LINE_C_FUNCTION_TO_FIND_WHETHER_A_NO_IS_POWER_OF_TWO_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class WRITE_ONE_LINE_C_FUNCTION_TO_FIND_WHETHER_A_NO_IS_POWER_OF_TWO_1{ static boolean f_gold ( int x ) { return x != 0 && ( ( x & ( x - 1 ) ) == 0 ) ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "99", "2" ], [ "33", "2" ], [ "50", "2" ], [ "17", "1" ], [ "18", "2" ], [ "69", "2" ], [ "23", "1" ], [ "18", "2" ], [ "94", "2" ], [ "16", "1" ] ]
f_gold
HARDY_RAMANUJAN_THEOREM
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class HARDY_RAMANUJAN_THEOREM{ static int f_gold ( int n ) { int count = 0 ; if ( n % 2 == 0 ) { count ++ ; while ( n % 2 == 0 ) n = n / 2 ; } for ( int i = 3 ; i <= Math . sqrt ( n ) ; i = i + 2 ) { if ( n % i == 0 ) { count ++ ; while ( n % i == 0 ) n = n / i ; } } if ( n > 2 ) count ++ ; return count ; }
[ "import math" ]
null
[]
[]
python
code_translation
def f_gold ( n , m ) : return n if ( n == m ) else 1
java
[ [ "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" ] ]
f_gold
GCD_ELEMENTS_GIVEN_RANGE
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class GCD_ELEMENTS_GIVEN_RANGE{ static int f_gold ( int n , int m ) { return ( n == m ) ? n : 1 ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "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" ] ]
f_gold
FIND_MINIMUM_SUM_FACTORS_NUMBER
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_MINIMUM_SUM_FACTORS_NUMBER{ static int f_gold ( int num ) { int sum = 0 ; for ( int i = 2 ; i * i <= num ; i ++ ) { while ( num % i == 0 ) { sum += i ; num /= i ; } } sum += num ; return sum ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : return ( 3.0 * n ) / ( 4.0 * ( n * n ) - 1 )
java
[ [ "46", "0.0163062743707905" ], [ "5", "0.15151515151515152" ], [ "44", "0.017047655947307245" ], [ "15", "0.05005561735261402" ], [ "72", "0.010417169037858692" ], [ "2", "0.4" ], [ "86", "0.008721225027887637" ], [ "17", "...
f_gold
PROBABILITY_THREE_RANDOMLY_CHOSEN_NUMBERS_AP
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PROBABILITY_THREE_RANDOMLY_CHOSEN_NUMBERS_AP{ static double f_gold ( int n ) { return ( 3.0 * n ) / ( 4.0 * ( n * n ) - 1 ) ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "[[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...
f_gold
GOLD_MINE_PROBLEM
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class GOLD_MINE_PROBLEM{ static int f_gold ( int gold [ ] [ ] , int m , int n ) { int goldTable [ ] [ ] = new int [ m ] [ n ] ; for ( int [ ] rows : goldTable ) Arrays . fill ( rows , 0 ) ; for ( int col = n - 1 ; col >= 0 ; col -- ) { for ( int row = 0 ; row < m ; row ++ ) { int right = ( col == n - 1 ) ? 0 : goldTable [ row ] [ col + 1 ] ; int right_up = ( row == 0 || col == n - 1 ) ? 0 : goldTable [ row - 1 ] [ col + 1 ] ; int right_down = ( row == m - 1 || col == n - 1 ) ? 0 : goldTable [ row + 1 ] [ col + 1 ] ; goldTable [ row ] [ col ] = gold [ row ] [ col ] + Math . max ( right , Math . max ( right_up , right_down ) ) ; ; } } int res = goldTable [ 0 ] [ 0 ] ; for ( int i = 1 ; i < m ; i ++ ) res = Math . max ( res , goldTable [ i ] [ 0 ] ) ; return res ; }
[]
null
[]
[]
python
code_translation
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 ) ;
java
[ [ "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" ] ]
f_gold
SUM_OF_ALL_PROPER_DIVISORS_OF_A_NATURAL_NUMBER
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class SUM_OF_ALL_PROPER_DIVISORS_OF_A_NATURAL_NUMBER{ static int f_gold ( int num ) { int result = 0 ; for ( int i = 2 ; i <= Math . sqrt ( num ) ; i ++ ) { if ( num % i == 0 ) { if ( i == ( num / i ) ) result += i ; else result += ( i + num / i ) ; } } return ( result + 1 ) ; }
[ "import math" ]
null
[]
[]
python
code_translation
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 ] )
java
[ [ "32", "55534064877048198" ], [ "52", "29869166945772625950142417512" ], [ "52", "29869166945772625950142417512" ], [ "32", "55534064877048198" ], [ "73", "79463489365077377841208237632349268884500" ], [ "31", "14544636039226909" ], [ "29"...
f_gold
COUNT_WAYS_DIVIDE_CIRCLE_USING_N_NON_INTERSECTING_CHORDS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class COUNT_WAYS_DIVIDE_CIRCLE_USING_N_NON_INTERSECTING_CHORDS{ static int f_gold ( int A ) { int n = 2 * A ; int [ ] dpArray = new int [ n + 1 ] ; dpArray [ 0 ] = 1 ; dpArray [ 2 ] = 1 ; for ( int i = 4 ; i <= n ; i += 2 ) { for ( int j = 0 ; j < i - 1 ; j += 2 ) { dpArray [ i ] += ( dpArray [ j ] * dpArray [ i - 2 - j ] ) ; } } return dpArray [ n ] ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "[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", ...
f_gold
FIND_SUM_UNIQUE_SUB_ARRAY_SUM_GIVEN_ARRAY
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_SUM_UNIQUE_SUB_ARRAY_SUM_GIVEN_ARRAY{ static int f_gold ( int [ ] arr , int n ) { int res = 0 ; HashMap < Integer , Integer > m = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int sum = 0 ; for ( int j = i ; j < n ; j ++ ) { sum += arr [ j ] ; if ( m . containsKey ( sum ) ) { m . put ( sum , m . get ( sum ) + 1 ) ; } else { m . put ( sum , 1 ) ; } } } for ( Map . Entry < Integer , Integer > x : m . entrySet ( ) ) if ( x . getValue ( ) == 1 ) res += x . getKey ( ) ; return res ; }
[]
null
[]
[]
python
code_translation
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 ]
java
[ [ "37", "11" ], [ "24", "2" ], [ "13", "5" ], [ "56", "3" ], [ "26", "5" ], [ "67", "11" ], [ "82", "11" ], [ "60", "4" ], [ "64", "1" ], [ "65", "7" ] ]
f_gold
FIND_N_TH_ELEMENT_FROM_STERNS_DIATOMIC_SERIES
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_N_TH_ELEMENT_FROM_STERNS_DIATOMIC_SERIES{ static int f_gold ( int n ) { int DP [ ] = new int [ n + 1 ] ; DP [ 0 ] = 0 ; DP [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { if ( i % 2 == 0 ) DP [ i ] = DP [ i / 2 ] ; else DP [ i ] = DP [ ( i - 1 ) / 2 ] + DP [ ( i + 1 ) / 2 ] ; } return DP [ n ] ; }
[]
null
[]
[]
python
code_translation
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 ]
java
[ [ "3", "3" ], [ "19", "24" ], [ "39", "57" ], [ "89", "152" ], [ "96", "192" ], [ "68", "114" ], [ "48", "83" ], [ "5", "5" ], [ "3", "3" ], [ "4", "4" ] ]
f_gold
MAXIMUM_VALUE_CHOICE_EITHER_DIVIDING_CONSIDERING
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MAXIMUM_VALUE_CHOICE_EITHER_DIVIDING_CONSIDERING{ static int f_gold ( int n ) { int res [ ] = new int [ n + 1 ] ; res [ 0 ] = 0 ; res [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) res [ i ] = Math . max ( i , ( res [ i / 2 ] + res [ i / 3 ] + res [ i / 4 ] + res [ i / 5 ] ) ) ; return res [ n ] ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : p = 1 if ( n and not ( n & ( n - 1 ) ) ) : return n while ( p < n ) : p <<= 1 return p ;
java
[ [ "8", "8" ], [ "79", "128" ], [ "31", "32" ], [ "63", "64" ], [ "18", "32" ], [ "2", "2" ], [ "6", "8" ], [ "85", "128" ], [ "29", "32" ], [ "8", "8" ] ]
f_gold
NEXT_POWER_OF_2_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class NEXT_POWER_OF_2_1{ static int f_gold ( int n ) { int p = 1 ; if ( n > 0 && ( n & ( n - 1 ) ) == 0 ) return n ; while ( p < n ) p <<= 1 ; return p ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "[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,...
f_gold
COUNT_PAIRS_DIFFERENCE_EQUAL_K
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class COUNT_PAIRS_DIFFERENCE_EQUAL_K{ static int f_gold ( int arr [ ] , int n , int k ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) if ( arr [ i ] - arr [ j ] == k || arr [ j ] - arr [ i ] == k ) count ++ ; } return count ; }
[]
null
[]
[]
python
code_translation
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 ]
java
[ [ "59", "9" ], [ "7", "3" ], [ "90", "13" ], [ "78", "11" ], [ "49", "6" ], [ "15", "6" ], [ "45", "13" ], [ "56", "6" ], [ "7", "3" ], [ "70", "12" ] ]
f_gold
MINIMUM_STEPS_MINIMIZE_N_PER_GIVEN_CONDITION
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MINIMUM_STEPS_MINIMIZE_N_PER_GIVEN_CONDITION{ static int f_gold ( int n ) { int table [ ] = new int [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) table [ i ] = n - i ; for ( int i = n ; i >= 1 ; i -- ) { if ( ! ( i % 2 > 0 ) ) table [ i / 2 ] = Math . min ( table [ i ] + 1 , table [ i / 2 ] ) ; if ( ! ( i % 3 > 0 ) ) table [ i / 3 ] = Math . min ( table [ i ] + 1 , table [ i / 3 ] ) ; } return table [ 1 ] ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : return 1 if ( n == 1 or n == 0 ) else n * f_gold ( n - 1 ) ;
java
[ [ "57", "40526919504877216755680601905432322134980384796226602145184481280000000000000" ], [ "28", "304888344611713860501504000000" ], [ "23", "25852016738884976640000" ], [ "79", "8946182130782975286851441715398316520698082167795719072138680632278379906935018605333618108...
f_gold
PROGRAM_FOR_FACTORIAL_OF_A_NUMBER_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PROGRAM_FOR_FACTORIAL_OF_A_NUMBER_1{ static int f_gold ( int n ) { int res = 1 , i ; for ( i = 2 ; i <= n ; i ++ ) res *= i ; return res ; }
[]
null
[]
[]
python
code_translation
def f_gold ( a , b , c , d ) : sum = a * a + b * b + c * c ; if ( d * d == sum ) : return True else : return False
java
[ [ "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...
f_gold
PYTHAGOREAN_QUADRUPLE
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PYTHAGOREAN_QUADRUPLE{ static Boolean f_gold ( int a , int b , int c , int d ) { int sum = a * a + b * b + c * c ; if ( d * d == sum ) return true ; else return false ; }
[]
null
[]
[]
python
code_translation
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 )
java
[ [ "371", "True" ], [ "9474", "True" ], [ "85", "False" ], [ "35", "False" ], [ "54", "False" ], [ "17", "False" ], [ "97", "False" ], [ "63", "False" ], [ "12", "False" ], [ "43", "False" ] ]
f_gold
PROGRAM_CHECK_PLUS_PERFECT_NUMBER
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PROGRAM_CHECK_PLUS_PERFECT_NUMBER{ static boolean f_gold ( int x ) { int temp = x ; int n = 0 ; while ( x != 0 ) { x /= 10 ; n ++ ; } x = temp ; int sum = 0 ; while ( x != 0 ) { sum += Math . pow ( x % 10 , n ) ; x /= 10 ; } return ( sum == temp ) ; }
[ "import math" ]
null
[]
[]
python
code_translation
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
java
[ [ "[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, ...
f_gold
MAXIMUM_SUBARRAY_SUM_ARRAY_CREATED_REPEATED_CONCATENATION
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MAXIMUM_SUBARRAY_SUM_ARRAY_CREATED_REPEATED_CONCATENATION{ static int f_gold ( int a [ ] , int n , int k ) { int max_so_far = 0 ; int INT_MIN , max_ending_here = 0 ; for ( int i = 0 ; i < n * k ; i ++ ) { 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 ; }
[]
null
[]
[]
python
code_translation
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
java
[ [ "[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,...
f_gold
FIND_WHETHER_AN_ARRAY_IS_SUBSET_OF_ANOTHER_ARRAY_SET_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_WHETHER_AN_ARRAY_IS_SUBSET_OF_ANOTHER_ARRAY_SET_1{ static boolean f_gold ( int arr1 [ ] , int arr2 [ ] , int m , int n ) { int i = 0 ; int j = 0 ; for ( i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < m ; j ++ ) if ( arr2 [ i ] == arr1 [ j ] ) break ; if ( j == m ) return false ; } return true ; }
[]
null
[]
[]
python
code_translation
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 ] )
java
[ [ "[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...
f_gold
MAXIMUM_AREA_RECTANGLE_PICKING_FOUR_SIDES_ARRAY
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MAXIMUM_AREA_RECTANGLE_PICKING_FOUR_SIDES_ARRAY{ static int f_gold ( Integer arr [ ] , int n ) { Arrays . sort ( arr , Collections . reverseOrder ( ) ) ; int [ ] dimension = { 0 , 0 }; for ( int i = 0 , j = 0 ; i < n - 1 && j < 2 ; i ++ ) if ( arr [ i ] == arr [ i + 1 ] ) dimension [ j ++ ] = arr [ i ++ ] ; return ( dimension [ 0 ] * dimension [ 1 ] ) ; }
[]
null
[]
[]
python
code_translation
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 ) )
java
[ [ "[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, ...
f_gold
INTEGER_POSITIVE_VALUE_POSITIVE_NEGATIVE_VALUE_ARRAY_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class INTEGER_POSITIVE_VALUE_POSITIVE_NEGATIVE_VALUE_ARRAY_1{ static int f_gold ( int arr [ ] , int n ) { int neg = 0 , pos = 0 ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; if ( arr [ i ] < 0 ) neg ++ ; else pos ++ ; } return ( sum / Math . abs ( neg - pos ) ) ; }
[]
null
[]
[]
python
code_translation
import itertools def f_gold ( n ) : count = 0 for curr in itertools.count ( ) : sum = 0 x = curr while ( x ) : sum = sum + x % 10 x = x // 10 if ( sum == 10 ) : count = count + 1 if ( count == n ) : return curr return - 1
java
[ [ "37", "406" ], [ "13", "136" ], [ "51", "613" ], [ "69", "1054" ], [ "76", "1126" ], [ "10", "109" ], [ "97", "1360" ], [ "40", "433" ], [ "69", "1054" ], [ "4", "46" ] ]
f_gold
N_TH_NUMBER_WHOSE_SUM_OF_DIGITS_IS_TEN
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class N_TH_NUMBER_WHOSE_SUM_OF_DIGITS_IS_TEN{ public static int f_gold ( int n ) { int count = 0 ; for ( int curr = 1 ; ; curr ++ ) { 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 ; } }
[ "import itertools" ]
null
[]
[]
python
code_translation
def f_gold ( mat , n ) : tot_energy = 0 for i in range ( n ) : for j in range ( n ) : q = mat [ i ] [ j ] // n i_des = q j_des = mat [ i ] [ j ] - ( n * q ) tot_energy += ( abs ( i_des - i ) + abs ( j_des - j ) ) return tot_energy
java
[ [ "[[4, 7, 10, 11, 14, 22, 27, 43, 45, 47, 48, 48, 49, 49, 51, 54, 56, 57, 59, 62, 63, 64, 66, 79, 82, 83, 87, 96, 97, 97, 98], [1, 1, 10, 13, 14, 18, 31, 33, 35, 37, 37, 42, 43, 44, 46, 54, 60, 61, 63, 63, 67, 67, 74, 76, 81, 83, 88, 91, 91, 96, 97], [2, 3, 4, 10, 11, 13, 17, 27, 30, 35, 35, 38, 39, 44, 47, 52...
f_gold
MINIMUM_COST_SORT_MATRIX_NUMBERS_0_N2_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MINIMUM_COST_SORT_MATRIX_NUMBERS_0_N2_1{ public static int f_gold ( int mat [ ] [ ] , int n ) { int i_des , j_des , q ; int tot_energy = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { q = mat [ i ] [ j ] / n ; i_des = q ; j_des = mat [ i ] [ j ] - ( n * q ) ; tot_energy += Math . abs ( i_des - i ) + Math . abs ( j_des - j ) ; } } return tot_energy ; }
[]