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 ( arr , n ) : sum = 0 arr.sort ( ) for i in range ( 0 , int ( n / 2 ) ) : sum -= ( 2 * arr [ i ] ) sum += ( 2 * arr [ n - i - 1 ] ) return sum
java
[ [ "[8, 9, 12, 13, 17, 21, 24, 29, 37, 37, 39, 40, 41, 45, 49, 50, 53, 54, 56, 59, 60, 60, 70, 71, 72, 74, 77, 77, 78, 85, 89, 89, 90, 90, 95, 98, 98], 34", "1454" ], [ "[-92, -84, -84, -84, -84, -80, -80, -80, -64, -52, -40, -32, -20, -18, -16, 0, 6, 14, 20, 26, 28, 30, 32, 32, 44, 48, 48, 52, 54, 6...
f_gold
MAXIMIZE_SUM_CONSECUTIVE_DIFFERENCES_CIRCULAR_ARRAY
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MAXIMIZE_SUM_CONSECUTIVE_DIFFERENCES_CIRCULAR_ARRAY{ static int f_gold ( int arr [ ] , int n ) { int sum = 0 ; Arrays . sort ( arr ) ; for ( int i = 0 ; i < n / 2 ; i ++ ) { sum -= ( 2 * arr [ i ] ) ; sum += ( 2 * arr [ n - i - 1 ] ) ; } return sum ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n , p ) : ans = 0 ; temp = p ; while ( temp <= n ) : ans += n / temp ; temp = temp * p ; return ans ;
java
[ [ "49, 30", "1.6333333333333333" ], [ "80, 25", "3.2" ], [ "10, 9", "1.1111111111111112" ], [ "81, 57", "1.4210526315789473" ], [ "11, 4", "2.75" ], [ "45, 34", "1.3235294117647058" ], [ "86, 90", "0" ], [ "27, 78", "0" ],...
f_gold
FINDING_POWER_PRIME_NUMBER_P_N
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FINDING_POWER_PRIME_NUMBER_P_N{ static int f_gold ( int n , int p ) { int ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int count = 0 , temp = i ; while ( temp % p == 0 ) { count ++ ; temp = temp / p ; } ans += count ; } return ans ; }
[]
null
[]
[]
python
code_translation
def f_gold ( arr , n ) : for i in range ( n ) : j = 0 while ( j < n ) : if ( i != j and arr [ i ] == arr [ j ] ) : break j += 1 if ( j == n ) : return arr [ i ] return - 1
java
[ [ "[1, 2, 3, 4, 6, 6, 7, 9, 10, 13, 16, 23, 30, 32, 36, 42, 42, 43, 44, 47, 48, 48, 49, 52, 52, 53, 55, 56, 58, 59, 60, 60, 63, 67, 68, 68, 74, 75, 76, 80, 81, 81, 83, 83, 86, 87, 91, 92, 97], 47", "1" ], [ "[-96, -46, -86, 56, -72, 50, 18, 8, 50], 8", "-96" ], [ "[0, 0, 0, 0, 0, 0, 0, 0...
f_gold
NON_REPEATING_ELEMENT
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class NON_REPEATING_ELEMENT{ static int f_gold ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { int j ; for ( j = 0 ; j < n ; j ++ ) if ( i != j && arr [ i ] == arr [ j ] ) break ; if ( j == n ) return arr [ i ] ; } return - 1 ; }
[]
null
[]
[]
python
code_translation
def f_gold(n): if (n <= 1): return False if (n <= 3): return True if (n % 2 == 0 or n % 3 == 0): return False i = 5 while (i * i <= n): if (n % i == 0 or n % (i + 2) == 0): return False i = i + 6 return True
java
[ [ "15", "False" ], [ "90", "False" ], [ "38", "False" ], [ "65", "False" ], [ "91", "False" ], [ "16", "False" ], [ "48", "False" ], [ "74", "False" ], [ "14", "False" ], [ "47", "True" ] ]
f_gold
PRIMALITY_TEST_SET_1_INTRODUCTION_AND_SCHOOL_METHOD_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PRIMALITY_TEST_SET_1_INTRODUCTION_AND_SCHOOL_METHOD_1{ static boolean f_gold ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 || n % 3 == 0 ) return false ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return false ; return true ; }
[]
null
[]
[]
python
code_translation
def f_gold ( arr , n ) : max = 0 for i in range ( n ) : for j in range ( n ) : if ( ( j - 3 ) >= 0 ) : result = ( arr [ i ] [ j ] * arr [ i ] [ j - 1 ] * arr [ i ] [ j - 2 ] * arr [ i ] [ j - 3 ] ) if ( max < result ) : max = result if ( ( i - 3 ) >= 0 ) : result = ( arr [ i ] [ j ] * arr [ i - 1 ] [ j ] * arr [ i - 2 ] [ j ] * arr [ i - 3 ] [ j ] ) if ( max < result ) : max = result if ( ( i - 3 ) >= 0 and ( j - 3 ) >= 0 ) : result = ( arr [ i ] [ j ] * arr [ i - 1 ] [ j - 1 ] * arr [ i - 2 ] [ j - 2 ] * arr [ i - 3 ] [ j - 3 ] ) if ( max < result ) : max = result return max
java
[ [ "[[1, 2, 5, 6, 7, 11, 12, 14, 15, 16, 19, 19, 24, 25, 32, 34, 36, 36, 38, 38, 39, 43, 43, 45, 47, 49, 51, 51, 51, 52, 53, 56, 59, 59, 67, 69, 70, 74, 75, 75, 77, 79, 81, 90, 94, 96, 96, 96], [1, 2, 4, 6, 9, 9, 9, 16, 18, 21, 23, 26, 26, 30, 36, 37, 37, 38, 39, 42, 45, 49, 51, 52, 52, 53, 56, 59, 61, 61, 64, 6...
f_gold
MAXIMUM_PRODUCT_OF_4_ADJACENT_ELEMENTS_IN_MATRIX
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MAXIMUM_PRODUCT_OF_4_ADJACENT_ELEMENTS_IN_MATRIX{ static int f_gold ( int arr [ ] [ ] , int n ) { int max = 0 , result ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( ( j - 3 ) >= 0 ) { result = arr [ i ] [ j ] * arr [ i ] [ j - 1 ] * arr [ i ] [ j - 2 ] * arr [ i ] [ j - 3 ] ; if ( max < result ) max = result ; } if ( ( i - 3 ) >= 0 ) { result = arr [ i ] [ j ] * arr [ i - 1 ] [ j ] * arr [ i - 2 ] [ j ] * arr [ i - 3 ] [ j ] ; if ( max < result ) max = result ; } if ( ( i - 3 ) >= 0 && ( j - 3 ) >= 0 ) { result = arr [ i ] [ j ] * arr [ i - 1 ] [ j - 1 ] * arr [ i - 2 ] [ j - 2 ] * arr [ i - 3 ] [ j - 3 ] ; if ( max < result ) max = result ; } } } return max ; }
[]
null
[]
[]
python
code_translation
def f_gold ( a , b , mod ) : res = 0 ; a = a % mod ; while ( b > 0 ) : if ( b % 2 == 1 ) : res = ( res + a ) % mod ; a = ( a * 2 ) % mod ; b //= 2 ; return res % mod ;
java
[ [ "99, 75, 40", "25" ], [ "11, 4, 41", "3" ], [ "51, 37, 23", "1" ], [ "49, 51, 88", "35" ], [ "9, 34, 30", "6" ], [ "90, 85, 55", "5" ], [ "19, 96, 41", "20" ], [ "17, 96, 37", "4" ], [ "54, 3, 51", "9" ], [...
f_gold
HOW_TO_AVOID_OVERFLOW_IN_MODULAR_MULTIPLICATION
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class HOW_TO_AVOID_OVERFLOW_IN_MODULAR_MULTIPLICATION{ static long f_gold ( long a , long b , long mod ) { long res = 0 ; a = a % mod ; while ( b > 0 ) { if ( b % 2 == 1 ) { res = ( res + a ) % mod ; } a = ( a * 2 ) % mod ; b /= 2 ; } return res % mod ; }
[]
null
[]
[]
python
code_translation
def f_gold ( text , word ) : word_list = text.split ( ) result = '' stars = '*' * len ( word ) count = 0 index = 0 ; for i in word_list : if i == word : word_list [ index ] = stars index += 1 result = ' '.join ( word_list ) return result
java
[ [ "'IggvAXtmJ', 'kzHdEJuCaO'", "'IggvAXtmJ'" ], [ "'76711241128', '5'", "'76711241128'" ], [ "'010', '0101001'", "'010'" ], [ "'HIKOn', 'XlnBwpx'", "'HIKOn'" ], [ "'3680369217', '017523'", "'3680369217'" ], [ "'1111', '1011'", "'1111'" ], [ ...
f_gold
PROGRAM_CENSOR_WORD_ASTERISKS_SENTENCE
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PROGRAM_CENSOR_WORD_ASTERISKS_SENTENCE{ static String f_gold ( String text , String word ) { String [ ] word_list = text . split ( "\\s+" ) ; String result = "" ; String stars = "" ; for ( int i = 0 ; i < word . length ( ) ; i ++ ) stars += '*' ; int index = 0 ; for ( String i : word_list ) { if ( i . compareTo ( word ) == 0 ) word_list [ index ] = stars ; index ++ ; } for ( String i : word_list ) result += i + ' ' ; return result ; }
[]
null
[]
[]
python
code_translation
def f_gold ( string ) : Stack = [ ] for ch in string : if ch == ')' : top = Stack.pop ( ) elementsInside = 0 while top != '(' : elementsInside += 1 top = Stack.pop ( ) if elementsInside < 1 : return True else : Stack.append ( ch ) return False
java
[ [ "'((a+b)+((c+d)))'", "True" ], [ "'(((a+(b)))+(c+d))'", "True" ], [ "'(((a+(b))+c+d))'", "True" ], [ "'((a+b)+(c+d))'", "False" ], [ "'(8582007)'", "False" ], [ "'((a+(b))+(c+d))'", "False" ], [ "'(PylsShEdKAE)'", "False" ], [ ...
f_gold
FIND_EXPRESSION_DUPLICATE_PARENTHESIS_NOT
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_EXPRESSION_DUPLICATE_PARENTHESIS_NOT{ static boolean f_gold ( String s ) { Stack < Character > Stack = new Stack < > ( ) ; char [ ] str = s . toCharArray ( ) ; for ( char ch : str ) { if ( ch == ')' ) { char top = Stack . peek ( ) ; Stack . pop ( ) ; int elementsInside = 0 ; while ( top != '(' ) { elementsInside ++ ; top = Stack . peek ( ) ; Stack . pop ( ) ; } if ( elementsInside < 1 ) { return true ; } } else { Stack . push ( ch ) ; } } return false ; }
[]
null
[]
[]
python
code_translation
def f_gold ( x1 , y1 , x2 , y2 ) : return ( float ) ( y2 - y1 ) / ( x2 - x1 )
java
[ [ "236.27324548309292, 5792.493225762838, 7177.837879115863, 1289.5700425822731", "-0.6486899453998202" ], [ "-9201.144918204123, -2716.3347716140406, -5161.142121227645, -3205.784279961129", "-0.12115078452752318" ], [ "3480.4716834445326, 3577.9608612055613, 8611.515262945342, 6744.864...
f_gold
PROGRAM_FIND_SLOPE_LINE
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PROGRAM_FIND_SLOPE_LINE{ static float f_gold ( float x1 , float y1 , float x2 , float y2 ) { return ( y2 - y1 ) / ( x2 - x1 ) ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : if ( n == 0 or n == 1 ) : return n f1 , f2 , f3 = 0 , 1 , 1 while ( f3 <= n ) : f1 = f2 ; f2 = f3 ; f3 = f1 + f2 ; return f2 ;
java
[ [ "54", "34" ], [ "71", "55" ], [ "64", "55" ], [ "71", "55" ], [ "96", "89" ], [ "43", "34" ], [ "70", "55" ], [ "94", "89" ], [ "95", "89" ], [ "69", "55" ] ]
f_gold
ZECKENDORFS_THEOREM_NON_NEIGHBOURING_FIBONACCI_REPRESENTATION
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class ZECKENDORFS_THEOREM_NON_NEIGHBOURING_FIBONACCI_REPRESENTATION{ public static int f_gold ( int n ) { if ( n == 0 || n == 1 ) return n ; int f1 = 0 , f2 = 1 , f3 = 1 ; while ( f3 <= n ) { f1 = f2 ; f2 = f3 ; f3 = f1 + f2 ; } return f2 ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : sum = 0 for row in range ( n ) : sum = sum + ( 1 << row ) return sum
java
[ [ "21", "2097151" ], [ "4", "15" ], [ "31", "2147483647" ], [ "79", "604462909807314587353087" ], [ "38", "274877906943" ], [ "75", "37778931862957161709567" ], [ "36", "68719476735" ], [ "32", "4294967295" ], [ "23"...
f_gold
SUM_OF_ALL_ELEMENTS_UP_TO_NTH_ROW_IN_A_PASCALS_TRIANGLE
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class SUM_OF_ALL_ELEMENTS_UP_TO_NTH_ROW_IN_A_PASCALS_TRIANGLE{ static long f_gold ( int n ) { long sum = 0 ; for ( int row = 0 ; row < n ; row ++ ) { sum = sum + ( 1 << row ) ; } return sum ; }
[]
null
[]
[]
python
code_translation
def f_gold ( x ) : m = 1 while ( x & m ) : x = x ^ m m <<= 1 x = x ^ m return x
java
[ [ "96", "97" ], [ "66", "67" ], [ "67", "68" ], [ "13", "14" ], [ "75", "76" ], [ "78", "79" ], [ "1", "2" ], [ "83", "84" ], [ "27", "28" ], [ "65", "66" ] ]
f_gold
ADD_1_TO_A_GIVEN_NUMBER
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class ADD_1_TO_A_GIVEN_NUMBER{ static int f_gold ( int x ) { int m = 1 ; while ( ( int ) ( x & m ) >= 1 ) { x = x ^ m ; m <<= 1 ; } x = x ^ m ; return x ; }
[]
null
[]
[]
python
code_translation
def f_gold ( arr , n , key ) : for i in range ( n ) : if ( arr [ i ] == key ) : return i return - 1
java
[ [ "[4, 8, 11, 23, 55, 57, 73, 74, 77, 79, 93], 8, 11", "2" ], [ "[-88, 12, -62, -66, -24, 18, 12, 22, 94, 30, -50, -42, -94, 18, 76, -6, -48, -68, 48, 36, -78, 52, -82, 76, 2, -44, -10, 88], 27, 12", "1" ], [ "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1], 11, 0", "0" ...
f_gold
SEARCH_INSERT_AND_DELETE_IN_AN_UNSORTED_ARRAY
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class SEARCH_INSERT_AND_DELETE_IN_AN_UNSORTED_ARRAY{ static int f_gold ( int arr [ ] , int n , int key ) { for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] == key ) return i ; return - 1 ; }
[]
null
[]
[]
python
code_translation
def f_gold ( a , n ) : x1 = a [ 0 ] x2 = 1 for i in range ( 1 , n ) : x1 = x1 ^ a [ i ] for i in range ( 2 , n + 2 ) : x2 = x2 ^ i return x1 ^ x2
java
[ [ "[2, 5, 7, 8, 10, 14, 27, 32, 51, 52, 57, 58, 65, 68, 68, 72, 73, 73, 83, 92, 98], 12", "50" ], [ "[-60, -48, 38, -78, 88, 86, -4, -94, 16, -64, 32, 88, 58, -78, -16, 48, 38, 30, 66, -60, 20, 40, -28, -64, -48, -86, -80, -8, -58, 52, 80, -32, 46, -4, -70, 76, -4, 78, -64, 38, -40], 28", "-91" ...
f_gold
FIND_THE_MISSING_NUMBER_2
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_THE_MISSING_NUMBER_2{ static int f_gold ( int a [ ] , int n ) { int x1 = a [ 0 ] ; int x2 = 1 ; for ( int i = 1 ; i < n ; i ++ ) x1 = x1 ^ a [ i ] ; for ( int i = 2 ; i <= n + 1 ; i ++ ) x2 = x2 ^ i ; return ( x1 ^ x2 ) ; }
[]
null
[]
[]
python
code_translation
def f_gold ( Str ) : Len = len ( Str ) res = [ None ] * Len index = 0 i = 0 s = [ ] s.append ( 0 ) while ( i < Len ) : if ( Str [ i ] == '+' ) : if ( s [ - 1 ] == 1 ) : res [ index ] = '-' index += 1 if ( s [ - 1 ] == 0 ) : res [ index ] = '+' index += 1 elif ( Str [ i ] == '-' ) : if ( s [ - 1 ] == 1 ) : res [ index ] = '+' index += 1 elif ( s [ - 1 ] == 0 ) : res [ index ] = '-' index += 1 elif ( Str [ i ] == '(' and i > 0 ) : if ( Str [ i - 1 ] == '-' ) : x = 0 if ( s [ - 1 ] == 1 ) else 1 s.append ( x ) elif ( Str [ i - 1 ] == '+' ) : s.append ( s [ - 1 ] ) elif ( Str [ i ] == ')' ) : s.pop ( ) else : res [ index ] = Str [ i ] index += 1 i += 1 return res
java
[ [ "'ggbsMvMZcMOVd'", "['g', 'g', 'b', 's', 'M', 'v', 'M', 'Z', 'c', 'M', 'O', 'V', 'd']" ], [ "'384292670'", "['3', '8', '4', '2', '9', '2', '6', '7', '0']" ], [ "'10000100'", "['1', '0', '0', '0', '0', '1', '0', '0']" ], [ "'fdHME'", "['f', 'd', 'H', 'M', 'E']" ], [ ...
f_gold
REMOVE_BRACKETS_ALGEBRAIC_STRING_CONTAINING_OPERATORS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class REMOVE_BRACKETS_ALGEBRAIC_STRING_CONTAINING_OPERATORS{ static String f_gold ( String str ) { int len = str . length ( ) ; char res [ ] = new char [ len ] ; int index = 0 , i = 0 ; Stack < Integer > s = new Stack < Integer > ( ) ; s . push ( 0 ) ; while ( i < len ) { if ( str . charAt ( i ) == '+' ) { if ( s . peek ( ) == 1 ) res [ index ++ ] = '-' ; if ( s . peek ( ) == 0 ) res [ index ++ ] = '+' ; } else if ( str . charAt ( i ) == '-' ) { if ( s . peek ( ) == 1 ) res [ index ++ ] = '+' ; else if ( s . peek ( ) == 0 ) res [ index ++ ] = '-' ; } else if ( str . charAt ( i ) == '(' && i > 0 ) { if ( str . charAt ( i - 1 ) == '-' ) { int x = ( s . peek ( ) == 1 ) ? 0 : 1 ; s . push ( x ) ; } else if ( str . charAt ( i - 1 ) == '+' ) s . push ( s . peek ( ) ) ; } else if ( str . charAt ( i ) == ')' ) s . pop ( ) ; else res [ index ++ ] = str . charAt ( i ) ; i ++ ; } return new String ( res ) ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n , p ) : ans = 0 temp = p while ( temp <= n ) : ans += n / temp temp = temp * p return int ( ans )
java
[ [ "76, 43", "1" ], [ "77, 91", "0" ], [ "9, 42", "0" ], [ "59, 67", "0" ], [ "8, 52", "0" ], [ "97, 8", "13" ], [ "78, 24", "3" ], [ "41, 88", "0" ], [ "72, 61", "1" ], [ "71, 28", "2" ] ]
f_gold
FINDING_POWER_PRIME_NUMBER_P_N_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FINDING_POWER_PRIME_NUMBER_P_N_1{ static int f_gold ( int n , int p ) { int ans = 0 ; int temp = p ; while ( temp <= n ) { ans += n / temp ; temp = temp * p ; } return ans ; }
[]
null
[]
[]
python
code_translation
def f_gold ( f , d , s ) : mem = [ [ 0 for i in range ( s + 1 ) ] for j in range ( d + 1 ) ] mem [ 0 ] [ 0 ] = 1 for i in range ( 1 , d + 1 ) : for j in range ( 1 , s + 1 ) : mem [ i ] [ j ] = mem [ i ] [ j - 1 ] + mem [ i - 1 ] [ j - 1 ] if j - f - 1 >= 0 : mem [ i ] [ j ] -= mem [ i - 1 ] [ j - f - 1 ] return mem [ d ] [ s ]
java
[ [ "57, 5, 33", "35960" ], [ "58, 45, 4", "0" ], [ "38, 89, 9", "0" ], [ "5, 39, 30", "0" ], [ "91, 90, 47", "0" ], [ "76, 56, 46", "0" ], [ "38, 43, 84", "839455243105945544513490" ], [ "97, 26, 52", "247959266474052" ], ...
f_gold
DICE_THROW_PROBLEM_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class DICE_THROW_PROBLEM_1{ public static long f_gold ( int f , int d , int s ) { long mem [ ] [ ] = new long [ d + 1 ] [ s + 1 ] ; mem [ 0 ] [ 0 ] = 1 ; for ( int i = 1 ; i <= d ; i ++ ) { for ( int j = i ; j <= s ; j ++ ) { mem [ i ] [ j ] = mem [ i ] [ j - 1 ] + mem [ i - 1 ] [ j - 1 ] ; if ( j - f - 1 >= 0 ) mem [ i ] [ j ] -= mem [ i - 1 ] [ j - f - 1 ] ; } } return mem [ d ] [ s ] ; }
[]
null
[]
[]
python
code_translation
def f_gold ( a , n ) : count = dict ( ) for i in range ( n ) : if count.get ( a [ i ] ) : count [ a [ i ] ] += 1 else : count [ a [ i ] ] = 1 ; next_missing = 1 for i in range ( n ) : if count [ a [ i ] ] != 1 or a [ i ] > n or a [ i ] < 1 : count [ a [ i ] ] -= 1 while count.get ( next_missing ) : next_missing += 1 a [ i ] = next_missing count [ next_missing ] = 1
java
[ [ "[19], 0", "None" ], [ "[1, 72], 1", "None" ], [ "[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 1, 1, 1, 1, 1, 1, 1, 1, 1], 18", "None" ], [ "[1, 3, 2, 4, 5, 6, 7, 8, 9, 20, 96, 71, 52, 33, 40, 39], 9", "None" ], [ "[1, 2, 3, 5, 6, 7, 8, 9, 10, 11...
f_gold
CHANGE_ARRAY_PERMUTATION_NUMBERS_1_N
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; class CHANGE_ARRAY_PERMUTATION_NUMBERS_1_N{ static void f_gold ( int [ ] a , int n ) { HashMap < Integer , Integer > count = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( count . containsKey ( a [ i ] ) ) { count . put ( a [ i ] , count . get ( a [ i ] ) + 1 ) ; } else { count . put ( a [ i ] , 1 ) ; } } int next_missing = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( count . containsKey ( a [ i ] ) && count . get ( a [ i ] ) != 1 || a [ i ] > n || a [ i ] < 1 ) { count . put ( a [ i ] , count . get ( a [ i ] ) - 1 ) ; while ( count . containsKey ( next_missing ) ) next_missing ++ ; a [ i ] = next_missing ; count . put ( next_missing , 1 ) ; } } }
[]
null
[]
[]
python
code_translation
def f_gold ( m , n ) : for i in range ( 0 , n ) : sum = 0 for j in range ( 0 , n ) : sum = sum + abs ( m [ i ] [ j ] ) sum = sum - abs ( m [ i ] [ i ] ) if ( abs ( m [ i ] [ i ] ) < sum ) : return False return True
java
[ [ "[[3, -2, 1], [1, -3, 2], [-1, 2, 4]], 2", "True" ], [ "[[2, -2, 1], [1, -3, 2], [-1, 2, 4]], 3", "False" ], [ "[[78, 46, 33, 58, 79, 94, 94, 31, 69], [83, 48, 11, 74, 33, 61, 88, 15, 29], [27, 20, 36, 14, 37, 88, 49, 36, 58], [93, 15, 39, 5, 97, 45, 1, 47, 34], [8, 88, 54, 87, 60, 77,...
f_gold
DIAGONALLY_DOMINANT_MATRIX
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class DIAGONALLY_DOMINANT_MATRIX{ static boolean f_gold ( int m [ ] [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { int sum = 0 ; for ( int j = 0 ; j < n ; j ++ ) sum += Math . abs ( m [ i ] [ j ] ) ; sum -= Math . abs ( m [ i ] [ i ] ) ; if ( Math . abs ( m [ i ] [ i ] ) < sum ) return false ; } return true ; }
[]
null
[]
[]
python
code_translation
def f_gold ( x , y , z ) : c = 0 while ( x and y and z ) : x = x - 1 y = y - 1 z = z - 1 c = c + 1 return c
java
[ [ "23, 98, 25", "23" ], [ "87, 55, 94", "55" ], [ "35, 90, 29", "29" ], [ "25, 9, 41", "9" ], [ "93, 22, 39", "22" ], [ "52, 42, 96", "42" ], [ "95, 88, 26", "26" ], [ "91, 64, 51", "51" ], [ "75, 1, 6", "1" ],...
f_gold
SMALLEST_OF_THREE_INTEGERS_WITHOUT_COMPARISON_OPERATORS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class SMALLEST_OF_THREE_INTEGERS_WITHOUT_COMPARISON_OPERATORS{ static int f_gold ( int x , int y , int z ) { int c = 0 ; while ( x != 0 && y != 0 && z != 0 ) { x -- ; y -- ; z -- ; c ++ ; } return c ; }
[]
null
[]
[]
python
code_translation
import sys def f_gold ( arr , n ) : min_ending_here = sys.maxsize min_so_far = sys.maxsize for i in range ( n ) : if ( min_ending_here > 0 ) : min_ending_here = arr [ i ] else : min_ending_here += arr [ i ] min_so_far = min ( min_so_far , min_ending_here ) return min_so_far
java
[ [ "[2, 9, 13, 14, 15, 18, 19, 19, 25, 26, 29, 29, 29, 30, 31, 36, 37, 37, 38, 39, 39, 40, 40, 42, 42, 46, 50, 53, 58, 60, 62, 64, 65, 67, 68, 69, 72, 77, 78, 83, 85, 89, 90, 93, 95, 95, 97], 24", "2" ], [ "[14, -58, 8, 78, -26, -20, -60, 42, -64, -12], 6", "-58" ], [ "[0, 0, 0, 0, 0, 0, ...
f_gold
SMALLEST_SUM_CONTIGUOUS_SUBARRAY
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class SMALLEST_SUM_CONTIGUOUS_SUBARRAY{ static int f_gold ( int arr [ ] , int n ) { int min_ending_here = 2147483647 ; int min_so_far = 2147483647 ; for ( int i = 0 ; i < n ; i ++ ) { if ( min_ending_here > 0 ) min_ending_here = arr [ i ] ; else min_ending_here += arr [ i ] ; min_so_far = Math . min ( min_so_far , min_ending_here ) ; } return min_so_far ; }
[ "import sys" ]
null
[]
[]
python
code_translation
import math def f_gold ( num ) : if ( num < 0 ) : return False c = ( - 2 * num ) b , a = 1 , 1 d = ( b * b ) - ( 4 * a * c ) if ( d < 0 ) : return False root1 = ( - b + math.sqrt ( d ) ) / ( 2 * a ) root2 = ( - b - math.sqrt ( d ) ) / ( 2 * a ) if ( root1 > 0 and math.floor ( root1 ) == root1 ) : return True if ( root2 > 0 and math.floor ( root2 ) == root2 ) : return True return False
java
[ [ "1", "True" ], [ "3", "True" ], [ "6", "True" ], [ "10", "True" ], [ "55", "True" ], [ "48", "False" ], [ "63", "False" ], [ "72", "False" ], [ "16", "False" ], [ "85", "False" ] ]
f_gold
TRIANGULAR_NUMBERS_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class TRIANGULAR_NUMBERS_1{ static boolean f_gold ( int num ) { if ( num < 0 ) return false ; int c = ( - 2 * num ) ; int b = 1 , a = 1 ; int d = ( b * b ) - ( 4 * a * c ) ; if ( d < 0 ) return false ; float root1 = ( - b + ( float ) Math . sqrt ( d ) ) / ( 2 * a ) ; float root2 = ( - b - ( float ) Math . sqrt ( d ) ) / ( 2 * a ) ; if ( root1 > 0 && Math . floor ( root1 ) == root1 ) return true ; if ( root2 > 0 && Math . floor ( root2 ) == root2 ) return true ; return false ; }
[ "import math" ]
null
[]
[]
python
code_translation
def f_gold(str1, str2, k): if ((len(str1) + len(str2)) < k): return True commonLength = 0 for i in range(0, min(len(str1), len(str2)), 1): if (str1[i] == str2[i]): commonLength += 1 else: break if ((k - len(str1) - len(str2) + 2 * commonLength) % 2 == 0): return True return False
java
[ [ "'ZNHGro', 'jAdbtDUYQu', 3", "False" ], [ "'382880806774', '65565', 10", "False" ], [ "'0', '00100010100', 2", "True" ], [ "'lxHTRFCTSQ', 'sViXYE', 89", "True" ], [ "'6399914758', '780990121', 9", "True" ], [ "'01100011100000', '0100', 0", "True"...
f_gold
CONVERTING_ONE_STRING_USING_APPEND_DELETE_LAST_OPERATIONS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class CONVERTING_ONE_STRING_USING_APPEND_DELETE_LAST_OPERATIONS{ static boolean f_gold ( String str1 , String str2 , int k ) { if ( ( str1 . length ( ) + str2 . length ( ) ) < k ) return true ; int commonLength = 0 ; for ( int i = 0 ; i < Math . min ( str1 . length ( ) , str2 . length ( ) ) ; i ++ ) { if ( str1 == str2 ) commonLength ++ ; else break ; } if ( ( k - str1 . length ( ) - str2 . length ( ) + 2 * commonLength ) % 2 == 0 ) return true ; return false ; }
[]
null
[]
[]
python
code_translation
def f_gold ( a1 , a2 , a3 , n1 , n2 , n3 , sum ) : s = set ( ) for i in range ( n1 ) : s.add ( a1 [ i ] ) for i in range ( n2 ) : for j in range ( n3 ) : if sum - a2 [ i ] - a3 [ j ] in s : return True return False
java
[ [ "[6, 7, 10, 15, 28, 30, 30, 35, 38, 43, 44, 44, 54, 55, 64, 68, 69, 73, 75, 75, 86, 87, 92, 93, 94], [11, 17, 18, 24, 26, 26, 33, 35, 38, 41, 55, 60, 63, 63, 69, 73, 78, 81, 82, 87, 90, 91, 93, 94, 99], [3, 3, 8, 22, 24, 24, 28, 30, 32, 32, 34, 39, 40, 45, 46, 50, 54, 59, 75, 78, 79, 90, 95, 95, 97], 21, 16, ...
f_gold
FIND_THREE_ELEMENT_FROM_DIFFERENT_THREE_ARRAYS_SUCH_THAT_THAT_A_B_C_K_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_THREE_ELEMENT_FROM_DIFFERENT_THREE_ARRAYS_SUCH_THAT_THAT_A_B_C_K_1{ static boolean f_gold ( int a1 [ ] , int a2 [ ] , int a3 [ ] , int n1 , int n2 , int n3 , int sum ) { HashSet < Integer > s = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < n1 ; i ++ ) { s . add ( a1 [ i ] ) ; } ArrayList < Integer > al = new ArrayList < > ( s ) ; for ( int i = 0 ; i < n2 ; i ++ ) { for ( int j = 0 ; j < n3 ; j ++ ) { if ( al . contains ( sum - a2 [ i ] - a3 [ j ] ) & al . indexOf ( sum - a2 [ i ] - a3 [ j ] ) != al . get ( al . size ( ) - 1 ) ) { return true ; } } } return false ; }
[]
null
[]
[]
python
code_translation
def f_gold ( N ) : if ( N <= 6 ) : return N screen = [ 0 ] * N for n in range ( 1 , 7 ) : screen [ n - 1 ] = n for n in range ( 7 , N + 1 ) : screen [ n - 1 ] = max ( 2 * screen [ n - 4 ] , max ( 3 * screen [ n - 5 ] , 4 * screen [ n - 6 ] ) ) ; return screen [ N - 1 ]
java
[ [ "41", "110592" ], [ "94", "274877906944" ], [ "80", "5435817984" ], [ "40", "82944" ], [ "76", "1811939328" ], [ "5", "5" ], [ "43", "196608" ], [ "67", "150994944" ], [ "24", "1024" ], [ "90", "869...
f_gold
HOW_TO_PRINT_MAXIMUM_NUMBER_OF_A_USING_GIVEN_FOUR_KEYS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class HOW_TO_PRINT_MAXIMUM_NUMBER_OF_A_USING_GIVEN_FOUR_KEYS{ static int f_gold ( int N ) { if ( N <= 6 ) return N ; int [ ] screen = new int [ N ] ; int b ; int n ; for ( n = 1 ; n <= 6 ; n ++ ) screen [ n - 1 ] = n ; for ( n = 7 ; n <= N ; n ++ ) { screen [ n - 1 ] = Math . max ( 2 * screen [ n - 4 ] , Math . max ( 3 * screen [ n - 5 ] , 4 * screen [ n - 6 ] ) ) ; } return screen [ N - 1 ] ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : res = 0 x = 0 while ( x * x < n ) : y = 0 while ( x * x + y * y < n ) : res = res + 1 y = y + 1 x = x + 1 return res
java
[ [ "61", "54" ], [ "45", "41" ], [ "53", "50" ], [ "4", "4" ], [ "82", "73" ], [ "86", "79" ], [ "37", "35" ], [ "48", "43" ], [ "81", "71" ], [ "50", "45" ] ]
f_gold
COUNT_DISTINCT_NON_NEGATIVE_PAIRS_X_Y_SATISFY_INEQUALITY_XX_YY_N_2
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{ static int f_gold ( int n ) { int res = 0 ; for ( int x = 0 ; x * x < n ; x ++ ) for ( int y = 0 ; x * x + y * y < n ; y ++ ) res ++ ; return res ; }
[]
null
[]
[]
python
code_translation
def f_gold ( m , x , revenue , n , t ) : maxRev = [ 0 ] * ( m + 1 ) nxtbb = 0 ; for i in range ( 1 , m + 1 ) : if ( nxtbb < n ) : if ( x [ nxtbb ] != i ) : maxRev [ i ] = maxRev [ i - 1 ] else : if ( i <= t ) : maxRev [ i ] = max ( maxRev [ i - 1 ] , revenue [ nxtbb ] ) else : maxRev [ i ] = max ( maxRev [ i - t - 1 ] + revenue [ nxtbb ] , maxRev [ i - 1 ] ) ; nxtbb += 1 else : maxRev [ i ] = maxRev [ i - 1 ] return maxRev [ m ]
java
[ [ "16, [6, 15, 15, 18, 23, 29, 32, 36, 37, 39, 40, 41, 44, 49, 51, 52, 53, 57, 66, 68, 82, 89, 96], [1, 2, 5, 5, 24, 26, 31, 32, 33, 41, 57, 59, 71, 75, 79, 87, 87, 88, 92, 94, 96, 96, 99], 12, 12", "2" ], [ "39, [76, 60, 88, 46, -20, -78, -22, 54, -18, 92, -42, -66, -90, -72, -48, 22, -72, -42, -46...
f_gold
HIGHWAY_BILLBOARD_PROBLEM
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class HIGHWAY_BILLBOARD_PROBLEM{ static int f_gold ( int m , int [ ] x , int [ ] revenue , int n , int t ) { int [ ] maxRev = new int [ m + 1 ] ; for ( int i = 0 ; i < m + 1 ; i ++ ) maxRev [ i ] = 0 ; int nxtbb = 0 ; for ( int i = 1 ; i <= m ; i ++ ) { if ( nxtbb < n ) { if ( x [ nxtbb ] != i ) maxRev [ i ] = maxRev [ i - 1 ] ; else { if ( i <= t ) maxRev [ i ] = Math . max ( maxRev [ i - 1 ] , revenue [ nxtbb ] ) ; else maxRev [ i ] = Math . max ( maxRev [ i - t - 1 ] + revenue [ nxtbb ] , maxRev [ i - 1 ] ) ; nxtbb ++ ; } } else maxRev [ i ] = maxRev [ i - 1 ] ; } return maxRev [ m ] ; }
[]
null
[]
[]
python
code_translation
def f_gold ( s ) : length = len ( s ) oneSeen = False count = 0 for i in range ( length ) : if ( s [ i ] == '1' and oneSeen ) : if ( s [ i - 1 ] == '0' ) : count += 1 if ( s [ i ] == '1' and oneSeen == 0 ) : oneSeen = True if ( s [ i ] != '0' and s [ i ] != '1' ) : oneSeen = False return count
java
[ [ "'1001ab010abc01001'", "2" ], [ "'1001010001'", "3" ], [ "'010100010100'", "3" ], [ "'DLCu'", "0" ], [ "'7072430592'", "0" ], [ "'011'", "0" ], [ "'pnJpypYOza'", "0" ], [ "'1037'", "0" ], [ "'111'", "0" ], ...
f_gold
COUNT_OF_OCCURRENCES_OF_A_101_PATTERN_IN_A_STRING
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class COUNT_OF_OCCURRENCES_OF_A_101_PATTERN_IN_A_STRING{ static int f_gold ( String str ) { int len = str . length ( ) ; boolean oneSeen = false ; int count = 0 ; for ( int i = 0 ; i < len ; i ++ ) { char getChar = str . charAt ( i ) ; if ( getChar == '1' && oneSeen == true ) { if ( str . charAt ( i - 1 ) == '0' ) count ++ ; } if ( getChar == '1' && oneSeen == false ) oneSeen = true ; if ( getChar != '0' && str . charAt ( i ) != '1' ) oneSeen = false ; } return count ; }
[]
null
[]
[]
python
code_translation
def f_gold ( a , b ) : if ( a == 0 or b == 0 ) : return False result = a * b if ( result >= 9223372036854775807 or result <= - 9223372036854775808 ) : result = 0 if ( a == ( result // b ) ) : print ( result // b ) return False else : return True
java
[ [ "37, 80", "False" ], [ "10000000000, -10000000000", "True" ], [ "10000000000, 10000000000", "True" ], [ "999999999, 999999999", "False" ], [ "39, 36", "False" ], [ "92, 56", "False" ], [ "14, 21", "False" ], [ "19, 38", "F...
f_gold
CHECK_INTEGER_OVERFLOW_MULTIPLICATION
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class CHECK_INTEGER_OVERFLOW_MULTIPLICATION{ static Boolean f_gold ( long a , long b ) { if ( a == 0 || b == 0 ) return false ; long result = a * b ; if ( a == result / b ) return false ; else return true ; }
[]
null
[]
[]
python
code_translation
def f_gold ( mat , n ) : diag1_left = 0 diag1_right = 0 diag2_left = 0 diag2_right = 0 i = 0 j = n - 1 while i < n : if ( i < n // 2 ) : diag1_left += mat [ i ] [ i ] diag2_left += mat [ j ] [ i ] elif ( i > n // 2 ) : diag1_right += mat [ i ] [ i ] diag2_right += mat [ j ] [ i ] i += 1 j -= 1 return ( diag1_left == diag2_right and diag2_right == diag2_left and diag1_right == diag2_left and diag2_right == mat [ n // 2 ] [ n // 2 ] )
java
[ [ "[[2, 9, 1, 4, -2], [6, 7, 2, 11, 4], [4, 2, 9, 2, 4], [1, 9, 2, 4, 4], [0, 2, 4, 2, 5]], 5", "True" ], [ "[[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, 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, 0, 0, 0, 0, 0, 0, 0, ...
f_gold
CENTER_ELEMENT_OF_MATRIX_EQUALS_SUMS_OF_HALF_DIAGONALS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class CENTER_ELEMENT_OF_MATRIX_EQUALS_SUMS_OF_HALF_DIAGONALS{ static boolean f_gold ( int mat [ ] [ ] , int n ) { int diag1_left = 0 , diag1_right = 0 ; int diag2_left = 0 , diag2_right = 0 ; for ( int i = 0 , j = n - 1 ; i < n ; i ++ , j -- ) { if ( i < n / 2 ) { diag1_left += mat [ i ] [ i ] ; diag2_left += mat [ j ] [ i ] ; } else if ( i > n / 2 ) { diag1_right += mat [ i ] [ i ] ; diag2_right += mat [ j ] [ i ] ; } } return ( diag1_left == diag2_right && diag2_right == diag2_left && diag1_right == diag2_left && diag2_right == mat [ n / 2 ] [ n / 2 ] ) ; }
[]
null
[]
[]
python
code_translation
def f_gold ( A , B , n ) : sorted ( A ) sorted ( B ) result = 0 for i in range ( n ) : result += ( A [ i ] * B [ n - i - 1 ] ) return result
java
[ [ "[31, 85], [18, 33], 1", "558" ], [ "[22, -6, 84, 70, 84, 6, 28, -74, -14, 68, 22, 90, -10], [2, -48, -36, -4, -22, -98, -74, -92, -72, -4, 48, -32, 94], 6", "-8900" ], [ "[0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 14", "1" ], ...
f_gold
MINIMIZE_SUM_PRODUCT_TWO_ARRAYS_PERMUTATIONS_ALLOWED
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MINIMIZE_SUM_PRODUCT_TWO_ARRAYS_PERMUTATIONS_ALLOWED{ static int f_gold ( int A [ ] , int B [ ] , int n ) { Arrays . sort ( A ) ; Arrays . sort ( B ) ; int result = 0 ; for ( int i = 0 ; i < n ; i ++ ) result += ( A [ i ] * B [ n - i - 1 ] ) ; return result ; }
[]
null
[]
[]
python
code_translation
def f_gold ( arr , n , k ) : max1 = max ( arr ) res = 0 for i in range ( 0 , n ) : if ( ( max1 - arr [ i ] ) % k != 0 ) : return - 1 else : res += ( max1 - arr [ i ] ) / k return int ( res )
java
[ [ "[4, 7, 19, 16], 4, 3", "10" ], [ "[4, 4, 4, 4, 4], 5, 3", "0" ], [ "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 39, 1", "24" ], [ "[85, 36, 52, 8, 52, 15, 16], 5, 6", "-1" ...
f_gold
MINIMUM_INCREMENT_K_OPERATIONS_MAKE_ELEMENTS_EQUAL
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MINIMUM_INCREMENT_K_OPERATIONS_MAKE_ELEMENTS_EQUAL{ static int f_gold ( int arr [ ] , int n , int k ) { Arrays . sort ( arr ) ; int max = arr [ arr . length - 1 ] ; int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( max - arr [ i ] ) % k != 0 ) return - 1 ; else res += ( max - arr [ i ] ) / k ; } return res ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : if ( n == 0 or n == 1 ) : return n return max ( ( f_gold ( n // 2 ) + f_gold ( n // 3 ) + f_gold ( n // 4 ) ) , n )
java
[ [ "39", "41" ], [ "79", "87" ], [ "7", "7" ], [ "76", "87" ], [ "48", "57" ], [ "18", "19" ], [ "58", "63" ], [ "17", "17" ], [ "36", "41" ], [ "5", "5" ] ]
f_gold
RECURSIVELY_BREAK_NUMBER_3_PARTS_GET_MAXIMUM_SUM
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{ static int f_gold ( int n ) { if ( n == 0 || n == 1 ) return n ; return Math . max ( ( f_gold ( n / 2 ) + f_gold ( n / 3 ) + f_gold ( n / 4 ) ) , n ) ; }
[]
null
[]
[]
python
code_translation
def f_gold ( arr , n ) : fw = [ 0 for k in range ( n ) ] bw = [ 0 for k in range ( n ) ] cur_max , max_so_far = arr [ 0 ] , arr [ 0 ] for i in range ( n ) : cur_max = max ( arr [ i ] , cur_max + arr [ i ] ) max_so_far = max ( max_so_far , cur_max ) fw [ i ] = cur_max cur_max = max_so_far = bw [ n - 1 ] = arr [ n - 1 ] i = n - 2 while i >= 0 : cur_max = max ( arr [ i ] , cur_max + arr [ i ] ) max_so_far = max ( max_so_far , cur_max ) bw [ i ] = cur_max i -= 1 fans = max_so_far for i in range ( 1 , n - 1 ) : fans = max ( fans , fw [ i - 1 ] + bw [ i + 1 ] ) return fans
java
[ [ "[2, 8, 14, 17, 19, 35, 38, 45, 50, 53, 55, 70, 82, 88, 92, 96], 13", "488" ], [ "[-64, -56, -80, -82, 72, 62, -8, 48, -96, 34, 64, -38, -60, 80, 4, -64, -62, 34, 94, -16, 38, 62, -84, 48, 42, -40], 22", "344" ], [ "[0, 0, 0, 0, 1, 1, 1], 6", "2" ], [ "[3, 7, 50, 53, 72, 14...
f_gold
MAXIMUM_SUM_SUBARRAY_REMOVING_ONE_ELEMENT
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MAXIMUM_SUM_SUBARRAY_REMOVING_ONE_ELEMENT{ static int f_gold ( int arr [ ] , int n ) { int fw [ ] = new int [ n ] ; int bw [ ] = new int [ n ] ; int cur_max = arr [ 0 ] , max_so_far = arr [ 0 ] ; fw [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { cur_max = Math . max ( arr [ i ] , cur_max + arr [ i ] ) ; max_so_far = Math . max ( max_so_far , cur_max ) ; fw [ i ] = cur_max ; } cur_max = max_so_far = bw [ n - 1 ] = arr [ n - 1 ] ; for ( int i = n - 2 ; i >= 0 ; i -- ) { cur_max = Math . max ( arr [ i ] , cur_max + arr [ i ] ) ; max_so_far = Math . max ( max_so_far , cur_max ) ; bw [ i ] = cur_max ; } int fans = max_so_far ; for ( int i = 1 ; i < n - 1 ; i ++ ) fans = Math . max ( fans , fw [ i - 1 ] + bw [ i + 1 ] ) ; return fans ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : while ( int ( n / 100 ) ) : last_digit = int ( n % 10 ) n = int ( n / 10 ) n += last_digit * 3 return ( n % 29 == 0 )
java
[ [ "29", "True" ], [ "0", "True" ], [ "65", "False" ], [ "1419", "False" ], [ "54", "False" ], [ "7", "False" ], [ "44", "False" ], [ "34", "False" ], [ "1160", "True" ], [ "292929002929", "True" ] ]
f_gold
NUMBER_IS_DIVISIBLE_BY_29_OR_NOT
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class NUMBER_IS_DIVISIBLE_BY_29_OR_NOT{ static boolean f_gold ( long n ) { while ( n / 100 > 0 ) { int last_digit = ( int ) n % 10 ; n /= 10 ; n += last_digit * 3 ; } return ( n % 29 == 0 ) ; }
[]
null
[]
[]
python
code_translation
def f_gold ( a , n ) : if ( n == 1 ) : return a [ 0 ] max_neg = float ( '-inf' ) min_pos = float ( 'inf' ) count_neg = 0 count_zero = 0 prod = 1 for i in range ( 0 , n ) : if ( a [ i ] == 0 ) : count_zero = count_zero + 1 continue if ( a [ i ] < 0 ) : count_neg = count_neg + 1 max_neg = max ( max_neg , a [ i ] ) if ( a [ i ] > 0 ) : min_pos = min ( min_pos , a [ i ] ) prod = prod * a [ i ] if ( count_zero == n or ( count_neg == 0 and count_zero > 0 ) ) : return 0 ; if ( count_neg == 0 ) : return min_pos if ( ( count_neg & 1 ) == 0 and count_neg != 0 ) : prod = int ( prod / max_neg ) return prod ;
java
[ [ "[3, 6, 7, 8, 8, 9, 12, 12, 12, 13, 15, 15, 15, 16, 18, 18, 18, 19, 20, 21, 22, 22, 23, 28, 29, 30, 30, 33, 33, 35, 35, 36, 40, 43, 58, 63, 73, 78, 82, 83, 84, 87, 89, 89, 92, 94], 23", "3" ], [ "[18, -6, -8, 98, 66, -86, 24, 6, 58, 74, 82], 10", "-297032800813056" ], [ "[0, 0, 0, 0, 0...
f_gold
MINIMUM_PRODUCT_SUBSET_ARRAY
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MINIMUM_PRODUCT_SUBSET_ARRAY{ static int f_gold ( int a [ ] , int n ) { if ( n == 1 ) return a [ 0 ] ; int negmax = Integer . MIN_VALUE ; int posmin = Integer . MAX_VALUE ; int count_neg = 0 , count_zero = 0 ; int product = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 0 ) { count_zero ++ ; continue ; } if ( a [ i ] < 0 ) { count_neg ++ ; negmax = Math . max ( negmax , a [ i ] ) ; } if ( a [ i ] > 0 && a [ i ] < posmin ) posmin = a [ i ] ; product *= a [ i ] ; } if ( count_zero == n || ( count_neg == 0 && count_zero > 0 ) ) return 0 ; if ( count_neg == 0 ) return posmin ; if ( count_neg % 2 == 0 && count_neg != 0 ) { product = product / negmax ; } return product ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : if n <= 1 : return False for i in range ( 2 , n ) : if n % i == 0 : return False ; return True
java
[ [ "37", "True" ], [ "39", "False" ], [ "73", "True" ], [ "8", "False" ], [ "28", "False" ], [ "66", "False" ], [ "20", "False" ], [ "36", "False" ], [ "6", "False" ], [ "51", "False" ] ]
f_gold
PRIMALITY_TEST_SET_1_INTRODUCTION_AND_SCHOOL_METHOD
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PRIMALITY_TEST_SET_1_INTRODUCTION_AND_SCHOOL_METHOD{ static boolean f_gold ( int n ) { if ( n <= 1 ) return false ; for ( int i = 2 ; i < n ; i ++ ) if ( n % i == 0 ) return false ; return true ; }
[]
null
[]
[]
python
code_translation
def f_gold ( str ) : for i in range ( 0 , len ( str ) ) : if ( str [ i ].istitle ( ) ) : return str [ i ] return 0
java
[ [ "'pH'", "'H'" ], [ "'96544000'", "0" ], [ "'000010000'", "0" ], [ "'ujqpx'", "0" ], [ "'20684847994'", "0" ], [ "'111'", "0" ], [ "'rclkv'", "0" ], [ "'45173693434'", "0" ], [ "'11111011001101'", "0" ], [ ...
f_gold
FIRST_UPPERCASE_LETTER_IN_A_STRING_ITERATIVE_AND_RECURSIVE
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIRST_UPPERCASE_LETTER_IN_A_STRING_ITERATIVE_AND_RECURSIVE{ static char f_gold ( String str ) { for ( int i = 0 ; i < str . length ( ) ; i ++ ) if ( Character . isUpperCase ( str . charAt ( i ) ) ) return str . charAt ( i ) ; return 0 ; }
[]
null
[]
[]
python
code_translation
def f_gold ( s , c ) : res = 0 for i in range ( len ( s ) ) : if ( s [ i ] == c ) : res = res + 1 return res
java
[ [ "'mhjnKfd', 'l'", "0" ], [ "'716662107', '6'", "3" ], [ "'01', '1'", "1" ], [ "'wPHSxIbnHakGRO', 'n'", "1" ], [ "'721106', '8'", "0" ], [ "'111', '0'", "0" ], [ "'TIBFU', 'Q'", "0" ], [ "'0', '3'", "0" ], [ "'10', ...
f_gold
PROGRAM_COUNT_OCCURRENCE_GIVEN_CHARACTER_STRING
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PROGRAM_COUNT_OCCURRENCE_GIVEN_CHARACTER_STRING{ public static int f_gold ( String s , char c ) { int res = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == c ) res ++ ; } return res ; }
[]
null
[]
[]
python
code_translation
import math def f_gold ( n ) : res = 1 while n % 2 == 0 : n = n // 2 for i in range ( 3 , int ( math.sqrt ( n ) + 1 ) ) : count = 0 curr_sum = 1 curr_term = 1 while n % i == 0 : count += 1 n = n // i curr_term *= i curr_sum += curr_term res *= curr_sum if n >= 2 : res *= ( 1 + n ) return res
java
[ [ "20", "6" ], [ "6", "4" ], [ "39", "56" ], [ "80", "6" ], [ "88", "12" ], [ "7", "8" ], [ "16", "1" ], [ "27", "40" ], [ "83", "84" ], [ "6", "4" ] ]
f_gold
FIND_SUM_ODD_FACTORS_NUMBER
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_SUM_ODD_FACTORS_NUMBER{ static int f_gold ( int n ) { int res = 1 ; while ( n % 2 == 0 ) n = n / 2 ; for ( int i = 3 ; i <= Math . sqrt ( n ) ; i ++ ) { int count = 0 , curr_sum = 1 ; int curr_term = 1 ; while ( n % i == 0 ) { count ++ ; n = n / i ; curr_term *= i ; curr_sum += curr_term ; } res *= curr_sum ; } if ( n >= 2 ) res *= ( 1 + n ) ; return res ; }
[ "import math" ]
null
[]
[]
python
code_translation
def f_gold ( num ) : length = len ( num ) if ( length == 1 and num [ 0 ] == '0' ) : return True if ( length % 3 == 1 ) : num = str ( num ) + "00" length += 2 elif ( length % 3 == 2 ) : num = str ( num ) + "0" length += 1 sum = 0 p = 1 for i in range ( length - 1 , - 1 , - 1 ) : group = 0 group += ord ( num [ i ] ) - ord ( '0' ) i -= 1 group += ( ord ( num [ i ] ) - ord ( '0' ) ) * 10 i -= 1 group += ( ord ( num [ i ] ) - ord ( '0' ) ) * 100 sum = sum + group * p p *= ( - 1 ) sum = abs ( sum ) return ( sum % 13 == 0 )
java
[ [ "'vzTUaItpCpLnjY'", "False" ], [ "'33855'", "True" ], [ "'0011110101011'", "True" ], [ "'MMQ'", "False" ], [ "'439340517954'", "True" ], [ "'000000000'", "True" ], [ "'UugAuRRJbjEgl'", "True" ], [ "'6406553695441'", "True"...
f_gold
CHECK_LARGE_NUMBER_DIVISIBLE_13_NOT
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class CHECK_LARGE_NUMBER_DIVISIBLE_13_NOT{ static boolean f_gold ( String num ) { int length = num . length ( ) ; if ( length == 1 && num . charAt ( 0 ) == '0' ) return true ; if ( length % 3 == 1 ) { num += "00" ; length += 2 ; } else if ( length % 3 == 2 ) { num += "0" ; length += 1 ; } int sum = 0 , p = 1 ; for ( int i = length - 1 ; i >= 0 ; i -- ) { int group = 0 ; group += num . charAt ( i -- ) - '0' ; group += ( num . charAt ( i -- ) - '0' ) * 10 ; group += ( num . charAt ( i ) - '0' ) * 100 ; sum = sum + group * p ; p *= ( - 1 ) ; } sum = Math . abs ( sum ) ; return ( sum % 13 == 0 ) ; }
[]
null
[]
[]
python
code_translation
def f_gold ( arr , n ) : ans = 0 maxele = max ( arr ) for i in range ( 2 , maxele + 1 ) : count = 0 for j in range ( n ) : if ( arr [ j ] % i == 0 ) : count += 1 ans = max ( ans , count ) return ans
java
[ [ "[10, 18, 22, 22, 22, 29, 30, 32, 33, 34, 37, 39, 40, 41, 44, 47, 49, 50, 50, 51, 53, 67, 69, 70, 71, 71, 73, 75, 78, 80, 81, 82, 91, 91, 93, 97, 97, 99], 35", "16" ], [ "[-42, 62, 6, 98, 38, -4, -38, 72, 42, 4, -22, -94, 78, -90, 14], 10", "10" ], [ "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
f_gold
LARGEST_SUBSEQUENCE_GCD_GREATER_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class LARGEST_SUBSEQUENCE_GCD_GREATER_1{ static int f_gold ( int arr [ ] , int n ) { int ans = 0 ; int maxele = Arrays . stream ( arr ) . max ( ) . getAsInt ( ) ; ; for ( int i = 2 ; i <= maxele ; ++ i ) { int count = 0 ; for ( int j = 0 ; j < n ; ++ j ) { if ( arr [ j ] % i == 0 ) ++ count ; } ans = Math . max ( ans , count ) ; } return ans ; }
[]
null
[]
[]
python
code_translation
def f_gold ( str ) : i = len ( str ) - 1 start = end = i + 1 result = '' while i >= 0 : if str [ i ] == ' ' : start = i + 1 while start != end : result += str [ start ] start += 1 result += ' ' end = i i -= 1 start = 0 while start != end : result += str [ start ] start += 1 return result
java
[ [ "'m Dm YZ'", "'YZ Dm m'" ], [ "'65 48 57 71'", "'71 57 48 65'" ], [ "'01 010'", "'010 01'" ], [ "'mT vhByi'", "'vhByi mT'" ], [ "'19 44 9 1'", "'1 9 44 19'" ], [ "'0'", "'0'" ], [ "'z vUi '", "' vUi z'" ], [ "'7 591 36643 9 ...
f_gold
PRINT_WORDS_STRING_REVERSE_ORDER
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PRINT_WORDS_STRING_REVERSE_ORDER{ static String f_gold ( String str ) { int i = str . length ( ) - 1 ; int start , end = i + 1 ; String result = "" ; while ( i >= 0 ) { if ( str . charAt ( i ) == ' ' ) { start = i + 1 ; while ( start != end ) result += str . charAt ( start ++ ) ; result += ' ' ; end = i ; } i -- ; } start = 0 ; while ( start != end ) result += str . charAt ( start ++ ) ; return result ; }
[]
null
[]
[]
python
code_translation
def f_gold ( N ) : B_Number = 0 cnt = 0 while ( N != 0 ) : rem = N % 2 c = pow ( 10 , cnt ) B_Number += rem * c N //= 2 cnt += 1 return B_Number
java
[ [ "18", "10010" ], [ "92", "1011100" ], [ "87", "1010111" ], [ "50", "110010" ], [ "56", "111000" ], [ "88", "1011000" ], [ "3", "11" ], [ "16", "10000" ], [ "45", "101101" ], [ "58", "111010" ] ]
f_gold
PROGRAM_DECIMAL_BINARY_CONVERSION_2
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PROGRAM_DECIMAL_BINARY_CONVERSION_2{ static int f_gold ( int N ) { int B_Number = 0 ; int cnt = 0 ; while ( N != 0 ) { int rem = N % 2 ; double c = Math . pow ( 10 , cnt ) ; B_Number += rem * c ; N /= 2 ; cnt ++ ; } return B_Number ; }
[]
null
[]
[]
python
code_translation
def f_gold ( b , m ) : return ( b / m - 1 ) * ( b / m ) / 2
java
[ [ "40, 74", "-0.1241782322863404" ], [ "38, 35", "0.04653061224489791" ], [ "47, 71", "-0.11188256298353501" ], [ "52, 29", "0.7110582639714625" ], [ "21, 9", "1.5555555555555558" ], [ "50, 33", "0.3902662993572084" ], [ "8, 82", "-0.04...
f_gold
MAXIMUM_NUMBER_OF_SQUARES_THAT_CAN_BE_FIT_IN_A_RIGHT_ANGLE_ISOSCELES_TRIANGLE
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MAXIMUM_NUMBER_OF_SQUARES_THAT_CAN_BE_FIT_IN_A_RIGHT_ANGLE_ISOSCELES_TRIANGLE{ static int f_gold ( int b , int m ) { return ( b / m - 1 ) * ( b / m ) / 2 ; }
[]
null
[]
[]
python
code_translation
def f_gold ( a , b , k ) : p = a ** b count = 0 while ( p > 0 and count < k ) : rem = p % 10 count = count + 1 if ( count == k ) : return rem p = p / 10 ;
java
[ [ "11, 2, 1", "1" ], [ "41, 3, 3", "9.210000000000036" ], [ "5, 4, 3", "6.25" ], [ "1, 2, 4", "0.001" ], [ "24, 1, 5", "0.0024000000000000002" ], [ "5, 2, 3", "0.25" ], [ "66, 5, 8", "5.233257599999973" ], [ "7, 10, 3", "2.4...
f_gold
K_TH_DIGIT_RAISED_POWER_B
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class K_TH_DIGIT_RAISED_POWER_B{ public static int f_gold ( int a , int b , int k ) { int p = ( int ) Math . pow ( a , b ) ; int count = 0 ; while ( p > 0 && count < k ) { int rem = p % 10 ; count ++ ; if ( count == k ) return rem ; p = p / 10 ; } return 0 ; }
[]
null
[]
[]
python
code_translation
def f_gold ( start , end , arr ) : frequency = dict ( ) for i in range ( start , end + 1 ) : if arr [ i ] in frequency.keys ( ) : frequency [ arr [ i ] ] += 1 else : frequency [ arr [ i ] ] = 1 count = 0 for x in frequency : if x == frequency [ x ] : count += 1 return count
java
[ [ "0, 31, [1, 2, 2, 3, 3, 3, 12, 13, 18, 18, 26, 28, 29, 36, 37, 39, 40, 49, 55, 57, 63, 69, 69, 73, 85, 86, 87, 87, 89, 89, 90, 91, 92, 93, 93, 93, 95, 99]", "3" ], [ "1, 25, [24, -62, 2, 1, 94, 56, -22, -70, -22, -34, -92, -18, 56, 2, 60, 38, -88, 16, -28, 30, -30, 58, -80, 94, 6, 56]", "2" ...
f_gold
ARRAY_RANGE_QUERIES_ELEMENTS_FREQUENCY_VALUE
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class ARRAY_RANGE_QUERIES_ELEMENTS_FREQUENCY_VALUE{ static int f_gold ( int start , int end , int arr [ ] ) { Map < Integer , Integer > mp = new HashMap < > ( ) ; for ( int i = start ; i <= end ; i ++ ) mp . put ( arr [ i ] , mp . get ( arr [ i ] ) == null ? 1 : mp . get ( arr [ i ] ) + 1 ) ; int count = 0 ; for ( Map . Entry < Integer , Integer > entry : mp . entrySet ( ) ) if ( entry . getKey ( ) == entry . getValue ( ) ) count ++ ; return count ; }
[]
null
[]
[]
python
code_translation
def f_gold ( arr , n , sum ) : for i in range ( n ) : curr_sum = arr [ i ] j = i + 1 while j <= n : if curr_sum == sum : print ( "Sum found between" ) print ( "indexes %d and %d" % ( i , j - 1 ) ) return 1 if curr_sum > sum or j == n : break curr_sum = curr_sum + arr [ j ] j += 1 print ( "No subarray found" ) return 0
java
[ [ "[4, 8, 8, 10, 15, 18, 19, 22, 25, 26, 30, 32, 35, 36, 40, 41, 43, 48, 53, 57, 59, 63, 64, 68, 71, 76, 76, 77, 78, 89, 96, 97], 26, 23", "0" ], [ "[-78, 16, -16, -10, -2, -38, 58, -72, -78, 50, -68, -16, -96, 82, 70, 2, -20], 9, 12", "0" ], [ "[0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]...
f_gold
FIND_SUBARRAY_WITH_GIVEN_SUM
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_SUBARRAY_WITH_GIVEN_SUM{ static int f_gold ( int arr [ ] , int n , int sum ) { int curr_sum , i , j ; for ( i = 0 ; i < n ; i ++ ) { curr_sum = arr [ i ] ; for ( j = i + 1 ; j <= n ; j ++ ) { if ( curr_sum == sum ) { int p = j - 1 ; System . out . println ( "Sum found between indexes " + i + " and " + p ) ; return 1 ; } if ( curr_sum > sum || j == n ) break ; curr_sum = curr_sum + arr [ j ] ; } } System . out . println ( "No subarray found" ) ; return 0 ; }
[]
null
[]
[]
python
code_translation
import sys def f_gold ( arr , n ) : res = - sys.maxsize for i in range ( 0 , n ) : curr_sum = 0 for j in range ( 0 , n ) : index = int ( ( i + j ) % n ) curr_sum += j * arr [ index ] res = max ( res , curr_sum ) return res
java
[ [ "[11, 12, 16, 26, 29, 40, 54, 59, 65, 70, 71, 73, 78, 81, 87, 87, 88, 90, 95, 97], 11", "3035" ], [ "[-46, -32, 54, 96, -72, -58, -36, -44, 26, -2, -68, 42, 90, 26, -92, -96, 88, -42, -18, 46, -70, 24, 0, 24, 34, 34, -52, 50, 94, -60, 64, 58], 22", "592" ], [ "[0, 0, 0, 0, 0, 0, 0, 0, ...
f_gold
MAXIMUM_SUM_IARRI_AMONG_ROTATIONS_GIVEN_ARRAY
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MAXIMUM_SUM_IARRI_AMONG_ROTATIONS_GIVEN_ARRAY{ static int f_gold ( int arr [ ] , int n ) { int res = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { int curr_sum = 0 ; for ( int j = 0 ; j < n ; j ++ ) { int index = ( i + j ) % n ; curr_sum += j * arr [ index ] ; } res = Math . max ( res , curr_sum ) ; } return res ; }
[ "import sys" ]
null
[]
[]
python
code_translation
def f_gold ( a , n , k ) : b = dict ( ) for i in range ( n ) : x = a [ i ] d = min ( 1 + i , n - i ) if x not in b.keys ( ) : b [ x ] = d else : b [ x ] = min ( d , b [ x ] ) ans = 10 ** 9 for i in range ( n ) : x = a [ i ] if ( x != ( k - x ) and ( k - x ) in b.keys ( ) ) : ans = min ( max ( b [ x ] , b [ k - x ] ) , ans ) return ans
java
[ [ "[2, 27, 66, 89, 96, 96], 4, 4", "1000000000" ], [ "[84, -38, -56, -20, -98, -40, -16, 22, 20, 98, -56, -32, -44, 30, -58, 26, -44, -32, 50, 46, 92], 13, 11", "1000000000" ], [ "[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], 23, 13", "1000000000" ], ...
f_gold
PRINT_MAXIMUM_SHORTEST_DISTANCE
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PRINT_MAXIMUM_SHORTEST_DISTANCE{ static int f_gold ( int a [ ] , int n , int k ) { HashMap < Integer , Integer > b = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int x = a [ i ] ; int d = Math . min ( 1 + i , n - i ) ; if ( ! b . containsKey ( x ) ) b . put ( x , d ) ; else { b . put ( x , Math . min ( d , b . get ( x ) ) ) ; } } int ans = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { int x = a [ i ] ; if ( x != k - x && b . containsKey ( k - x ) ) ans = Math . min ( Math . max ( b . get ( x ) , b . get ( k - x ) ) , ans ) ; } return ans ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : return int ( ( ( n + 1 ) * ( n + 2 ) ) / 2 )
java
[ [ "41", "903" ], [ "72", "2701" ], [ "54", "1540" ], [ "75", "2926" ], [ "87", "3916" ], [ "41", "903" ], [ "78", "3160" ], [ "80", "3321" ], [ "46", "1128" ], [ "9", "55" ] ]
f_gold
NUMBER_NON_NEGATIVE_INTEGRAL_SOLUTIONS_B_C_N_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class NUMBER_NON_NEGATIVE_INTEGRAL_SOLUTIONS_B_C_N_1{ static int f_gold ( int n ) { return ( ( n + 1 ) * ( n + 2 ) ) / 2 ; }
[]
null
[]
[]
python
code_translation
def f_gold ( a , b , x , y ) : if a == 0 : x = 0 y = 1 return b x1 = 1 y1 = 1 gcd = f_gold ( b % a , a , x1 , y1 ) x = y1 - ( b / a ) * x1 y = x1 return gcd
java
[ [ "44, 17, 10, 65", "1" ], [ "33, 81, 67, 20", "3" ], [ "39, 77, 21, 34", "1" ], [ "52, 96, 23, 97", "4" ], [ "64, 48, 17, 33", "16" ], [ "45, 32, 89, 3", "1" ], [ "53, 88, 24, 74", "1" ], [ "86, 19, 29, 21", "1" ], [ ...
f_gold
BASIC_AND_EXTENDED_EUCLIDEAN_ALGORITHMS_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class BASIC_AND_EXTENDED_EUCLIDEAN_ALGORITHMS_1{ public static int f_gold ( int a , int b , int x , int y ) { if ( a == 0 ) { x = 0 ; y = 1 ; return b ; } int x1 = 1 , y1 = 1 ; int gcd = f_gold ( b % a , a , x1 , y1 ) ; x = y1 - ( b / a ) * x1 ; y = x1 ; return gcd ; }
[]
null
[]
[]
python
code_translation
def f_gold ( str ) : n = len ( str ) C = [ [ 0 for i in range ( n ) ] for i in range ( n ) ] P = [ [ False for i in range ( n ) ] for i in range ( n ) ] j = 0 k = 0 L = 0 for i in range ( n ) : P [ i ] [ i ] = True ; C [ i ] [ i ] = 0 ; for L in range ( 2 , n + 1 ) : for i in range ( n - L + 1 ) : j = i + L - 1 if L == 2 : P [ i ] [ j ] = ( str [ i ] == str [ j ] ) else : P [ i ] [ j ] = ( ( str [ i ] == str [ j ] ) and P [ i + 1 ] [ j - 1 ] ) if P [ i ] [ j ] == True : C [ i ] [ j ] = 0 else : C [ i ] [ j ] = 100000000 for k in range ( i , j ) : C [ i ] [ j ] = min ( C [ i ] [ j ] , C [ i ] [ k ] + C [ k + 1 ] [ j ] + 1 ) return C [ 0 ] [ n - 1 ]
java
[ [ "'ydYdV'", "2" ], [ "'4446057'", "4" ], [ "'0111'", "1" ], [ "'keEj'", "3" ], [ "'642861576557'", "10" ], [ "'11111000101'", "2" ], [ "'ram'", "2" ], [ "'09773261'", "6" ], [ "'1'", "0" ], [ "'AVBEKClFd...
f_gold
DYNAMIC_PROGRAMMING_SET_17_PALINDROME_PARTITIONING
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class DYNAMIC_PROGRAMMING_SET_17_PALINDROME_PARTITIONING{ static int f_gold ( String str ) { int n = str . length ( ) ; int [ ] [ ] C = new int [ n ] [ n ] ; boolean [ ] [ ] P = new boolean [ n ] [ n ] ; int i , j , k , L ; for ( i = 0 ; i < n ; i ++ ) { P [ i ] [ i ] = true ; C [ i ] [ i ] = 0 ; } for ( L = 2 ; L <= n ; L ++ ) { for ( i = 0 ; i < n - L + 1 ; i ++ ) { j = i + L - 1 ; if ( L == 2 ) P [ i ] [ j ] = ( str . charAt ( i ) == str . charAt ( j ) ) ; else P [ i ] [ j ] = ( str . charAt ( i ) == str . charAt ( j ) ) && P [ i + 1 ] [ j - 1 ] ; if ( P [ i ] [ j ] == true ) C [ i ] [ j ] = 0 ; else { C [ i ] [ j ] = Integer . MAX_VALUE ; for ( k = i ; k <= j - 1 ; k ++ ) C [ i ] [ j ] = Integer . min ( C [ i ] [ j ] , C [ i ] [ k ] + C [ k + 1 ] [ j ] + 1 ) ; } } } return C [ 0 ] [ n - 1 ] ; }
[]
null
[]
[]
python
code_translation
def f_gold ( stri , n ) : m = dict ( ) for i in range ( n ) : m [ stri [ i ] ] = m.get ( stri [ i ] , 0 ) + 1 res = 0 for i in m.values ( ) : if i == 2 : res += 1 return res
java
[ [ "['hate', 'love', 'peace', 'love', 'peace', 'hate', 'love', 'peace', 'love', 'peace'], 10", "1" ], [ "['16', '946613197072', '532052', '42780833', '511552', '1241934', '4', '3444540', '47487223670074', '23753', '14158', '4', '95420017116714', '16', '0845', '689000748', '976403809728', '8922', '487...
f_gold
COUNT_WORDS_APPEAR_EXACTLY_TWO_TIMES_ARRAY_WORDS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class COUNT_WORDS_APPEAR_EXACTLY_TWO_TIMES_ARRAY_WORDS{ static int f_gold ( String str [ ] , int n ) { HashMap < String , Integer > m = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( m . containsKey ( str [ i ] ) ) { int get = m . get ( str [ i ] ) ; m . put ( str [ i ] , get + 1 ) ; } else { m . put ( str [ i ] , 1 ) ; } } int res = 0 ; for ( Map . Entry < String , Integer > it : m . entrySet ( ) ) { if ( it . getValue ( ) == 2 ) res ++ ; } return res ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : n -= 1 n |= n >> 1 n |= n >> 2 n |= n >> 4 n |= n >> 8 n |= n >> 16 n += 1 return n
java
[ [ "63", "64" ], [ "78", "128" ], [ "13", "16" ], [ "5", "8" ], [ "34", "64" ], [ "69", "128" ], [ "63", "64" ], [ "78", "128" ], [ "80", "128" ], [ "19", "32" ] ]
f_gold
NEXT_POWER_OF_2_2
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class NEXT_POWER_OF_2_2{ static int f_gold ( int n ) { n -- ; n |= n >> 1 ; n |= n >> 2 ; n |= n >> 4 ; n |= n >> 8 ; n |= n >> 16 ; n ++ ; return n ; }
[]
null
[]
[]
python
code_translation
def f_gold ( A , B , m , n ) : dp = [ [ 0 for i in range ( m + 1 ) ] for j in range ( n + 1 ) ] for i in range ( 1 , n + 1 , 1 ) : for j in range ( i , m + 1 , 1 ) : dp [ i ] [ j ] = max ( ( dp [ i - 1 ] [ j - 1 ] + ( A [ j - 1 ] * B [ i - 1 ] ) ) , dp [ i ] [ j - 1 ] ) return dp [ n ] [ m ]
java
[ [ "[7, 9, 22, 68], [14, 22, 54, 58], 3, 2", "610" ], [ "[24, 40, 98, 58, -24, 24, 76, 48, -92, -16, -46, -48, -70, 88, 66, 2, 44, 36, 34, 34, 46, 90, -80, -24, -58, 68, 72, -20, -62, -40], [30, -88, 6, -26, -76, 14, -80, -30, -58, 76, 40, -28, -54, 38, -60, -60, 88, -80, -22, 90, 50, -48, 68, -26, 2...
f_gold
FIND_MAXIMUM_DOT_PRODUCT_TWO_ARRAYS_INSERTION_0S
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_MAXIMUM_DOT_PRODUCT_TWO_ARRAYS_INSERTION_0S{ static int f_gold ( int A [ ] , int B [ ] , int m , int n ) { int dp [ ] [ ] = new int [ n + 1 ] [ m + 1 ] ; for ( int [ ] row : dp ) Arrays . fill ( row , 0 ) ; for ( int i = 1 ; i <= n ; i ++ ) for ( int j = i ; j <= m ; j ++ ) dp [ i ] [ j ] = Math . max ( ( dp [ i - 1 ] [ j - 1 ] + ( A [ j - 1 ] * B [ i - 1 ] ) ) , dp [ i ] [ j - 1 ] ) ; return dp [ n ] [ m ] ; }
[]
null
[]
[]
python
code_translation
def f_gold ( arr , n ) : s = [ ] j = 0 ans = 0 for i in range ( n ) : while ( j < n and ( arr [ j ] not in s ) ) : s.append ( arr [ j ] ) j += 1 ans += ( ( j - i ) * ( j - i + 1 ) ) // 2 s.remove ( arr [ i ] ) return ans
java
[ [ "[3, 4, 5, 6, 12, 15, 16, 17, 20, 20, 22, 24, 24, 27, 28, 34, 37, 39, 39, 41, 43, 49, 49, 51, 55, 62, 63, 67, 71, 74, 74, 74, 77, 84, 84, 89, 89, 97, 99], 24", "255" ], [ "[-8, 54, -22, 18, 20, 44, 0, 54, 90, -4, 4, 40, -74, -16], 13", "335" ], [ "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
f_gold
SUBARRAYS_DISTINCT_ELEMENTS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class SUBARRAYS_DISTINCT_ELEMENTS{ public static int f_gold ( int [ ] arr , int n ) { Set < Integer > s = new HashSet < > ( ) ; int j = 0 , ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { while ( j < n && ! s . contains ( arr [ j ] ) ) { s . add ( arr [ i ] ) ; j ++ ; } ans += ( ( j - i ) * ( j - i + 1 ) ) / 2 ; s . remove ( arr [ i ] ) ; } return ans ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : return 1 if ( n == 1 or n == 0 ) else n * f_gold ( n - 1 )
java
[ [ "24", "620448401733239439360000" ], [ "46", "5502622159812088949850305428800254892961651752960000000000" ], [ "47", "258623241511168180642964355153611979969197632389120000000000" ], [ "41", "33452526613163807108170062053440751665152000000000" ], [ "98", "942...
f_gold
PROGRAM_FOR_FACTORIAL_OF_A_NUMBER_2
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class PROGRAM_FOR_FACTORIAL_OF_A_NUMBER_2{ static int f_gold ( int n ) { return ( n == 1 || n == 0 ) ? 1 : n * f_gold ( n - 1 ) ; }
[]
null
[]
[]
python
code_translation
def f_gold ( x ) : if ( x == 0 or x == 1 ) : return x start = 1 end = x while ( start <= end ) : mid = ( start + end ) // 2 if ( mid * mid == x ) : return mid if ( mid * mid < x ) : start = mid + 1 ans = mid else : end = mid - 1 return ans
java
[ [ "40", "6" ], [ "10", "3" ], [ "46", "6" ], [ "54", "7" ], [ "1", "1" ], [ "67", "8" ], [ "64", "8" ], [ "10", "3" ], [ "75", "8" ], [ "11", "3" ] ]
f_gold
SQUARE_ROOT_OF_AN_INTEGER_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class SQUARE_ROOT_OF_AN_INTEGER_1{ public static int f_gold ( int x ) { if ( x == 0 || x == 1 ) return x ; int start = 1 , end = x , ans = 0 ; while ( start <= end ) { int mid = ( start + end ) / 2 ; if ( mid * mid == x ) return mid ; if ( mid * mid < x ) { start = mid + 1 ; ans = mid ; } else end = mid - 1 ; } return ans ; }
[]
null
[]
[]
python
code_translation
def f_gold ( a , n ) : cnt = dict ( ) ans = 0 pre_sum = 0 for i in range ( n ) : ans += ( i * a [ i ] ) - pre_sum pre_sum += a [ i ] if ( a [ i ] - 1 ) in cnt : ans -= cnt [ a [ i ] - 1 ] if ( a [ i ] + 1 ) in cnt : ans += cnt [ a [ i ] + 1 ] if a [ i ] not in cnt : cnt [ a [ i ] ] = 0 cnt [ a [ i ] ] += 1 return ans
java
[ [ "[2, 8, 12, 19, 23, 23, 26, 39, 54, 56, 57, 57, 73, 78, 83, 83, 89, 91], 15", "3278" ], [ "[62, -34, 10, -28, -42, -12, 4, 20, -20, -84, -76, -16, -44, 26, -78, -40, 50, -10, -56, 76, -88, 24, 64, 10, 64, -8, -68, -42, 26, 24, 62, 36, -68, 8, -68, -2, 8, 38, -18], 20", "-112" ], [ "[0,...
f_gold
SUM_FAI_AJ_PAIRS_ARRAY_N_INTEGERS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class SUM_FAI_AJ_PAIRS_ARRAY_N_INTEGERS{ public static int f_gold ( int a [ ] , int n ) { Map < Integer , Integer > cnt = new HashMap < Integer , Integer > ( ) ; int ans = 0 , pre_sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ans += ( i * a [ i ] ) - pre_sum ; pre_sum += a [ i ] ; if ( cnt . containsKey ( a [ i ] - 1 ) ) ans -= cnt . get ( a [ i ] - 1 ) ; if ( cnt . containsKey ( a [ i ] + 1 ) ) ans += cnt . get ( a [ i ] + 1 ) ; if ( cnt . containsKey ( a [ i ] ) ) { cnt . put ( a [ i ] , cnt . get ( a [ i ] ) + 1 ) ; } else { cnt . put ( a [ i ] , 1 ) ; } } return ans ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : if ( n == 0 or n == 9 ) : return True if ( n < 9 ) : return False return f_gold ( ( int ) ( n >> 3 ) - ( int ) ( n & 7 ) )
java
[ [ "96", "False" ], [ "85", "False" ], [ "54", "True" ], [ "14", "False" ], [ "47", "False" ], [ "11", "False" ], [ "49", "False" ], [ "99", "True" ], [ "28", "False" ], [ "82", "False" ] ]
f_gold
DIVISIBILITY_9_USING_BITWISE_OPERATORS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class DIVISIBILITY_9_USING_BITWISE_OPERATORS{ static boolean f_gold ( int n ) { if ( n == 0 || n == 9 ) return true ; if ( n < 9 ) return false ; return f_gold ( ( int ) ( n >> 3 ) - ( int ) ( n & 7 ) ) ; }
[]
null
[]
[]
python
code_translation
def f_gold ( s ) : n = len ( s ) ; sub_count = ( n * ( n + 1 ) ) // 2 ; arr = [ 0 ] * sub_count ; index = 0 ; for i in range ( n ) : for j in range ( 1 , n - i + 1 ) : arr [ index ] = s [ i : i + j ] ; index += 1 ; arr.sort ( ) ; res = "" ; for i in range ( sub_count ) : res += arr [ i ] ; return res ;
java
[ [ "'sqGOi'", "'GGOGOiOOiiqqGqGOqGOissqsqGsqGOsqGOi'" ], [ "'848580'", "'04484854858485805585808888084848848584858848580858588580'" ], [ "'01001110011001'", "'000000000000000100100100110011001100011000011001001110011100011100001110010011100110011100110001110011000011100110010101010101...
f_gold
LEXICOGRAPHICAL_CONCATENATION_SUBSTRINGS_STRING
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class LEXICOGRAPHICAL_CONCATENATION_SUBSTRINGS_STRING{ static String f_gold ( String s ) { int n = s . length ( ) ; int sub_count = n * ( n + 1 ) / 2 ; String [ ] arr = new String [ sub_count ] ; int index = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int len = 1 ; len <= n - i ; len ++ ) { arr [ index ++ ] = s . substring ( i , i + len ) ; } Arrays . sort ( arr ) ; String res = "" ; for ( int i = 0 ; i < sub_count ; i ++ ) res += arr [ i ] ; return res ; }
[]
null
[]
[]
python
code_translation
def f_gold ( x , y ) : if ( y == 0 ) : return 1 elif ( int ( y % 2 ) == 0 ) : return ( f_gold ( x , int ( y / 2 ) ) * f_gold ( x , int ( y / 2 ) ) ) else : return ( x * f_gold ( x , int ( y / 2 ) ) * f_gold ( x , int ( y / 2 ) ) )
java
[ [ "46, 92", "941283649136660906908287235589050394624915053389458552934497600337861569560091909525670688971469335226973410396408482954990038586235954171670711989436416" ], [ "99, 87", "4171208799332206753818167125120365451389126990842805836632072138079363644083332067927083108134418913010210832875...
f_gold
WRITE_A_C_PROGRAM_TO_CALCULATE_POWXN
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class WRITE_A_C_PROGRAM_TO_CALCULATE_POWXN{ static int f_gold ( int x , int y ) { if ( y == 0 ) return 1 ; else if ( y % 2 == 0 ) return f_gold ( x , y / 2 ) * f_gold ( x , y / 2 ) ; else return x * f_gold ( x , y / 2 ) * f_gold ( x , y / 2 ) ; }
[]
null
[]
[]
python
code_translation
def f_gold ( s ) : aCount = 0 bCount = 0 cCount = 0 for i in range ( len ( s ) ) : if ( s [ i ] == 'a' ) : aCount = ( 1 + 2 * aCount ) elif ( s [ i ] == 'b' ) : bCount = ( aCount + 2 * bCount ) elif ( s [ i ] == 'c' ) : cCount = ( bCount + 2 * cCount ) return cCount
java
[ [ "''", "0" ], [ "'abbc'", "3" ], [ "'abcabc'", "7" ], [ "'agsdbkfdc '", "1" ], [ "'ababab'", "0" ], [ "'aaaaaaa'", "0" ], [ "'aabaaabcc'", "111" ], [ "'19'", "0" ], [ "'1001100'", "0" ], [ "'DtAnuQbU'", ...
f_gold
NUMBER_SUBSEQUENCES_FORM_AI_BJ_CK
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class NUMBER_SUBSEQUENCES_FORM_AI_BJ_CK{ static int f_gold ( String s ) { int aCount = 0 ; int bCount = 0 ; int cCount = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == 'a' ) aCount = ( 1 + 2 * aCount ) ; else if ( s . charAt ( i ) == 'b' ) bCount = ( aCount + 2 * bCount ) ; else if ( s . charAt ( i ) == 'c' ) cCount = ( bCount + 2 * cCount ) ; } return cCount ; }
[]
null
[]
[]
python
code_translation
def f_gold ( X , Y , m , n ) : LCSuff = [ [ 0 for k in range ( n + 1 ) ] for l in range ( m + 1 ) ] result = 0 for i in range ( m + 1 ) : for j in range ( n + 1 ) : if ( i == 0 or j == 0 ) : LCSuff [ i ] [ j ] = 0 elif ( X [ i - 1 ] == Y [ j - 1 ] ) : LCSuff [ i ] [ j ] = LCSuff [ i - 1 ] [ j - 1 ] + 1 result = max ( result , LCSuff [ i ] [ j ] ) else : LCSuff [ i ] [ j ] = 0 return result
java
[ [ "['A', 'D', 'E', 'E', 'L', 'L', 'T', 'r', 'x'], ['D', 'F', 'H', 'O', 'g', 'o', 'u', 'v', 'w'], 4, 4", "1" ], [ "['9', '3', '4', '8', '7', '6', '3', '8', '3', '3', '5', '3', '5', '4', '2', '5', '5', '3', '6', '2', '1', '7', '4', '2', '7', '3', '2', '1', '3', '7', '6', '5', '0', '6', '3', '8', '5', ...
f_gold
LONGEST_COMMON_SUBSTRING
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class LONGEST_COMMON_SUBSTRING{ static int f_gold ( char X [ ] , char Y [ ] , int m , int n ) { int LCStuff [ ] [ ] = new int [ m + 1 ] [ n + 1 ] ; int result = 0 ; for ( int i = 0 ; i <= m ; i ++ ) { for ( int j = 0 ; j <= n ; j ++ ) { if ( i == 0 || j == 0 ) LCStuff [ i ] [ j ] = 0 ; else if ( X [ i - 1 ] == Y [ j - 1 ] ) { LCStuff [ i ] [ j ] = LCStuff [ i - 1 ] [ j - 1 ] + 1 ; result = Integer . max ( result , LCStuff [ i ] [ j ] ) ; } else LCStuff [ i ] [ j ] = 0 ; } } return result ; }
[]
null
[]
[]
python
code_translation
def f_gold ( arr , low , high , x ) : if x <= arr [ low ] : return low if x > arr [ high ] : return - 1 mid = ( low + high ) / 2 ; if arr [ mid ] == x : return mid elif arr [ mid ] < x : if mid + 1 <= high and x <= arr [ mid + 1 ] : return mid + 1 else : return f_gold ( arr , mid + 1 , high , x ) else : if mid - 1 >= low and x > arr [ mid - 1 ] : return mid else : return f_gold ( arr , low , mid - 1 , x )
java
[ [ "[2, 6, 13, 16, 23, 24, 24, 27, 30, 32, 34, 34, 55, 56, 56, 63, 66, 81, 83, 96], 13, 11, 18", "13" ], [ "[-28, -96, 48, 22, -12, 72, 48, -70, -96, -84, -62, 22, 18, -92, -74, 14, 28, 52, 64, 72, 16, -76, 46], 11, 18, 21", "11" ], [ "[0, 1], 1, 1, 1", "1" ], [ "[51, 98, 25, ...
f_gold
CEILING_IN_A_SORTED_ARRAY_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class CEILING_IN_A_SORTED_ARRAY_1{ static int f_gold ( int arr [ ] , int low , int high , int x ) { int mid ; if ( x <= arr [ low ] ) return low ; if ( x > arr [ high ] ) return - 1 ; mid = ( low + high ) / 2 ; if ( arr [ mid ] == x ) return mid ; else if ( arr [ mid ] < x ) { if ( mid + 1 <= high && x <= arr [ mid + 1 ] ) return mid + 1 ; else return f_gold ( arr , mid + 1 , high , x ) ; } else { if ( mid - 1 >= low && x > arr [ mid - 1 ] ) return mid ; else return f_gold ( arr , low , mid - 1 , x ) ; } }
[]
null
[]
[]
python
code_translation
import sys def f_gold ( arr , n ) : res = - sys.maxsize - 1 for i in range ( n ) : prefix_sum = arr [ i ] for j in range ( i ) : prefix_sum += arr [ j ] suffix_sum = arr [ i ] j = n - 1 while ( j > i ) : suffix_sum += arr [ j ] j -= 1 if ( prefix_sum == suffix_sum ) : res = max ( res , prefix_sum ) return res
java
[ [ "[3, 3, 9, 19, 22, 27, 32, 41, 45, 63, 66, 67, 81, 91], 13", "-9223372036854775808" ], [ "[-64, -2, 68, -48, 22, -14, -98], 4", "-9223372036854775808" ], [ "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 19", "5" ], [ "[86, 79, 23, 55, 4, 22, 37, 1, ...
f_gold
MAXIMUM_EQULIBRIUM_SUM_ARRAY
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MAXIMUM_EQULIBRIUM_SUM_ARRAY{ static int f_gold ( int [ ] arr , int n ) { int res = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { int prefix_sum = arr [ i ] ; for ( int j = 0 ; j < i ; j ++ ) prefix_sum += arr [ j ] ; int suffix_sum = arr [ i ] ; for ( int j = n - 1 ; j > i ; j -- ) suffix_sum += arr [ j ] ; if ( prefix_sum == suffix_sum ) res = Math . max ( res , prefix_sum ) ; } return res ; }
[ "import sys" ]
null
[]
[]
python
code_translation
def f_gold ( low , high ) : f1 , f2 , f3 = 0 , 1 , 1 result = 0 while ( f1 <= high ) : if ( f1 >= low ) : result += 1 f1 = f2 f2 = f3 f3 = f1 + f2 return result
java
[ [ "76, 43", "0" ], [ "96, 52", "0" ], [ "19, 79", "3" ], [ "36, 2", "0" ], [ "60, 11", "0" ], [ "20, 15", "0" ], [ "76, 4", "0" ], [ "63, 93", "1" ], [ "2, 25", "6" ], [ "41, 39", "0" ] ]
f_gold
COUNT_FIBONACCI_NUMBERS_GIVEN_RANGE_LOG_TIME
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class COUNT_FIBONACCI_NUMBERS_GIVEN_RANGE_LOG_TIME{ static int f_gold ( int low , int high ) { int f1 = 0 , f2 = 1 , f3 = 1 ; int result = 0 ; while ( f1 <= high ) { if ( f1 >= low ) result ++ ; f1 = f2 ; f2 = f3 ; f3 = f1 + f2 ; } return result ; }
[]
null
[]
[]
python
code_translation
def f_gold ( arr , n , x ) : curr_sum = 0 ; min_len = n + 1 ; start = 0 ; end = 0 ; while ( end < n ) : while ( curr_sum <= x and end < n ) : if ( curr_sum <= 0 and x > 0 ) : start = end ; curr_sum = 0 ; curr_sum += arr [ end ] ; end += 1 ; while ( curr_sum > x and start < n ) : if ( end - start < min_len ) : min_len = end - start ; curr_sum -= arr [ start ] ; start += 1 ; return min_len ;
java
[ [ "[2, 4, 5, 10, 14, 15, 16, 20, 23, 28, 31, 35, 36, 36, 43, 48, 49, 55, 57, 57, 58, 61, 64, 64, 68, 70, 70, 73, 74, 76, 76, 77, 81, 81, 82, 87, 89, 92, 99], 33, 28", "1" ], [ "[66, -20, 12, -48, 22, 28, 40, -30, -6, -96, 10, -88, 40], 11, 12", "1" ], [ "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
f_gold
MINIMUM_LENGTH_SUBARRAY_SUM_GREATER_GIVEN_VALUE_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MINIMUM_LENGTH_SUBARRAY_SUM_GREATER_GIVEN_VALUE_1{ static int f_gold ( int arr [ ] , int n , int x ) { int curr_sum = 0 , min_len = n + 1 ; int start = 0 , end = 0 ; while ( end < n ) { while ( curr_sum <= x && end < n ) { if ( curr_sum <= 0 && x > 0 ) { start = end ; curr_sum = 0 ; } curr_sum += arr [ end ++ ] ; } while ( curr_sum > x && start < n ) { if ( end - start < min_len ) min_len = end - start ; curr_sum -= arr [ start ++ ] ; } } return min_len ; }
[]
null
[]
[]
python
code_translation
def f_gold ( arr , n , k ) : for i in range ( n ) : count = 0 for j in range ( n ) : if arr [ j ] == arr [ i ] : count += 1 if count > 2 * k : return False return True
java
[ [ "[1, 1, 2, 3, 1], 5, 2", "True" ], [ "[2, 3, 3, 5, 3, 3], 6, 2", "True" ], [ "[0, 0, 1, 1, 1], 2, 1", "True" ], [ "[7, 60, 78, 91, 80, 75, 85, 21, 41, 63, 1, 84, 69, 13, 94, 25, 54, 54, 52, 68, 53, 35, 17, 37, 98, 27, 2, 31], 24, 2", "True" ], [ "[-96, -94, -82,...
f_gold
DISTRIBUTING_ITEMS_PERSON_CANNOT_TAKE_TWO_ITEMS_TYPE
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class DISTRIBUTING_ITEMS_PERSON_CANNOT_TAKE_TWO_ITEMS_TYPE{ static boolean f_gold ( int [ ] arr , int n , int k ) { int count ; for ( int i = 0 ; i < n ; i ++ ) { count = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( arr [ j ] == arr [ i ] ) count ++ ; if ( count > 2 * k ) return false ; } } return true ; }
[]
null
[]
[]
python
code_translation
def f_gold ( array , start , end ) : if ( start > end ) : return end + 1 if ( start != array [ start ] ) : return start ; mid = int ( ( start + end ) / 2 ) if ( array [ mid ] == mid ) : return f_gold ( array , mid + 1 , end ) return f_gold ( array , start , mid )
java
[ [ "[3, 6, 7, 9, 11, 14, 18, 30, 30, 32, 32, 34, 37, 44, 45, 45, 48, 48, 48, 52, 58, 60, 63, 67, 69, 69, 81, 83, 87, 89, 97, 99], 24, 18", "19" ], [ "[88, -62, 16, 80, 66, 78, 88, 38, 52, -96, 48, 98, 96, -62, 18, 34, -58, 30, -10, 26, -98, 48, -96, 4, 92, 36, 36, -36, -32, -70, 62, -58, -58, -84, 86...
f_gold
FIND_THE_FIRST_MISSING_NUMBER
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_THE_FIRST_MISSING_NUMBER{ static int f_gold ( int array [ ] , int start , int end ) { if ( start > end ) return end + 1 ; if ( start != array [ start ] ) return start ; int mid = ( start + end ) / 2 ; if ( array [ mid ] == mid ) return f_gold ( array , mid + 1 , end ) ; return f_gold ( array , start , mid ) ; }
[]
null
[]
[]
python
code_translation
def f_gold ( x , p1 , p2 , n ) : set1 = ( x >> p1 ) & ( ( 1 << n ) - 1 ) set2 = ( x >> p2 ) & ( ( 1 << n ) - 1 ) xor = ( set1 ^ set2 ) xor = ( xor << p1 ) | ( xor << p2 ) result = x ^ xor return result
java
[ [ "95, 88, 97, 92", "95" ], [ "16, 26, 59, 42", "16" ], [ "55, 56, 40, 41", "55" ], [ "75, 35, 79, 30", "75" ], [ "90, 12, 59, 34", "90" ], [ "58, 65, 25, 19", "58" ], [ "69, 64, 17, 94", "69" ], [ "5, 1, 59, 38", "115292150...
f_gold
SWAP_BITS_IN_A_GIVEN_NUMBER
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class SWAP_BITS_IN_A_GIVEN_NUMBER{ static int f_gold ( int x , int p1 , int p2 , int n ) { int set1 = ( x >> p1 ) & ( ( 1 << n ) - 1 ) ; int set2 = ( x >> p2 ) & ( ( 1 << n ) - 1 ) ; int xor = ( set1 ^ set2 ) ; xor = ( xor << p1 ) | ( xor << p2 ) ; int result = x ^ xor ; return result ; }
[]
null
[]
[]
python
code_translation
def f_gold ( X , Y , m , n ) : res = 0 X.sort ( reverse = True ) Y.sort ( reverse = True ) hzntl = 1 ; vert = 1 i = 0 ; j = 0 while ( i < m and j < n ) : if ( X [ i ] > Y [ j ] ) : res += X [ i ] * vert hzntl += 1 i += 1 else : res += Y [ j ] * hzntl vert += 1 j += 1 total = 0 while ( i < m ) : total += X [ i ] i += 1 res += total * vert total = 0 while ( j < n ) : total += Y [ j ] j += 1 res += total * hzntl return res
java
[ [ "[98, 97, 93, 90, 90, 87, 87, 87, 83, 77, 75, 73, 70, 70, 69, 67, 67, 61, 60, 59, 58, 58, 56, 53, 52, 46, 46, 44, 40, 37, 34, 33, 33, 33, 32, 28, 26, 25, 25, 23, 22, 22, 20, 18, 16, 9, 9, 1], [99, 97, 96, 95, 92, 91, 88, 87, 86, 77, 74, 73, 73, 72, 71, 70, 70, 67, 63, 62, 60, 59, 56, 55, 55, 55, 50, 47, 45, 3...
f_gold
MINIMUM_COST_CUT_BOARD_SQUARES
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MINIMUM_COST_CUT_BOARD_SQUARES{ static int f_gold ( Integer X [ ] , Integer Y [ ] , int m , int n ) { int res = 0 ; Arrays . sort ( X , Collections . reverseOrder ( ) ) ; Arrays . sort ( Y , Collections . reverseOrder ( ) ) ; int hzntl = 1 , vert = 1 ; int i = 0 , j = 0 ; while ( i < m && j < n ) { if ( X [ i ] > Y [ j ] ) { res += X [ i ] * vert ; hzntl ++ ; i ++ ; } else { res += Y [ j ] * hzntl ; vert ++ ; j ++ ; } } int total = 0 ; while ( i < m ) total += X [ i ++ ] ; res += total * vert ; total = 0 ; while ( j < n ) total += Y [ j ++ ] ; res += total * hzntl ; return res ; }
[]
null
[]
[]
python
code_translation
def f_gold(x, y, n): sum = 0 for i in range(n): for j in range(i + 1, n): sum += (abs(x[i] - x[j]) + abs(y[i] - y[j])) return sum
java
[ [ "[2, 4, 6, 6, 8, 11, 12, 13, 14, 19, 20, 22, 24, 28, 29, 30, 32, 35, 37, 44, 48, 49, 51, 51, 56, 59, 59, 62, 65, 68, 68, 68, 72, 75, 77, 78, 89, 89, 91, 93, 95, 99], [6, 19, 19, 22, 25, 27, 31, 33, 34, 35, 37, 38, 38, 44, 46, 50, 51, 55, 58, 58, 64, 64, 64, 64, 65, 66, 66, 66, 67, 70, 75, 78, 79, 81, 81, 81, ...
f_gold
SUM_MANHATTAN_DISTANCES_PAIRS_POINTS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class SUM_MANHATTAN_DISTANCES_PAIRS_POINTS{ static int f_gold ( int x [ ] , int y [ ] , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) sum += ( Math . abs ( x [ i ] - x [ j ] ) + Math . abs ( y [ i ] - y [ j ] ) ) ; return sum ; }
[]
null
[]
[]
python
code_translation
import math def f_gold ( n ) : fibo = 2.078087 * math.log ( n ) + 1.672276 return round ( fibo )
java
[ [ "20", "8" ], [ "95", "11" ], [ "39", "9" ], [ "21", "8" ], [ "94", "11" ], [ "79", "11" ], [ "56", "10" ], [ "62", "10" ], [ "23", "8" ], [ "3", "4" ] ]
f_gold
FIND_INDEX_GIVEN_FIBONACCI_NUMBER_CONSTANT_TIME_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_INDEX_GIVEN_FIBONACCI_NUMBER_CONSTANT_TIME_1{ static int f_gold ( int n ) { float fibo = 2.078087F * ( float ) Math . log ( n ) + 1.672276F ; return Math . round ( fibo ) ; }
[ "import math" ]
null
[]
[]
python
code_translation
def f_gold ( n , x ) : cnt = 0 for i in range ( 1 , n + 1 ) : if i <= x : if x // i <= n and x % i == 0 : cnt += 1 return cnt
java
[ [ "47, 30", "8" ], [ "57, 16", "5" ], [ "55, 63", "4" ], [ "11, 23", "0" ], [ "55, 49", "3" ], [ "63, 64", "5" ], [ "64, 98", "4" ], [ "28, 30", "6" ], [ "49, 61", "0" ], [ "48, 64", "5" ] ]
f_gold
COUNT_ENTRIES_EQUAL_TO_X_IN_A_SPECIAL_MATRIX
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class COUNT_ENTRIES_EQUAL_TO_X_IN_A_SPECIAL_MATRIX{ static int f_gold ( int n , int x ) { int f_gold = 0 ; for ( int i = 1 ; i <= n && i <= x ; i ++ ) { if ( x / i <= n && x % i == 0 ) f_gold ++ ; } return f_gold ; }
[]
null
[]
[]
python
code_translation
def f_gold(n): if (n < 4): return - 1 rem = n % 4 if (rem == 0): return n // 4 if (rem == 1): if (n < 9): return - 1 return (n - 9) // 4 + 1 if (rem == 2): return (n - 6) // 4 + 1 if (rem == 3): if (n < 15): return - 1 return (n - 15) // 4 + 2
java
[ [ "55", "12" ], [ "35", "7" ], [ "24", "6" ], [ "75", "17" ], [ "5", "-1" ], [ "7", "-1" ], [ "50", "12" ], [ "28", "7" ], [ "67", "15" ], [ "59", "13" ] ]
f_gold
SPLIT_N_MAXIMUM_COMPOSITE_NUMBERS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class SPLIT_N_MAXIMUM_COMPOSITE_NUMBERS{ static int f_gold ( int n ) { if ( n < 4 ) return - 1 ; int rem = n % 4 ; if ( rem == 0 ) return n / 4 ; if ( rem == 1 ) { if ( n < 9 ) return - 1 ; return ( n - 9 ) / 4 + 1 ; } if ( rem == 2 ) return ( n - 6 ) / 4 + 1 ; if ( rem == 3 ) { if ( n < 15 ) return - 1 ; return ( n - 15 ) / 4 + 2 ; } return 0 ; }
[]
null
[]
[]
python
code_translation
def f_gold ( s , t ) : count = 0 for i in range ( 0 , len ( t ) ) : if ( count == len ( s ) ) : break if ( t [ i ] == s [ count ] ) : count = count + 1 return count
java
[ [ "'nObYIOjEQZ', 'uARTDTQbmGI'", "0" ], [ "'84574', '8538229'", "1" ], [ "'1010001010010', '11'", "1" ], [ "'DjZtAfUudk', 'OewGm'", "0" ], [ "'550', '132744553919'", "2" ], [ "'1110', '0101'", "2" ], [ "'GywyxwH', 'LPQqEqrDZiwY'", "0" ...
f_gold
MAXIMUM_LENGTH_PREFIX_ONE_STRING_OCCURS_SUBSEQUENCE_ANOTHER
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MAXIMUM_LENGTH_PREFIX_ONE_STRING_OCCURS_SUBSEQUENCE_ANOTHER{ static int f_gold ( String s , String t ) { int count = 0 ; for ( int i = 0 ; i < t . length ( ) ; i ++ ) { if ( count == t . length ( ) ) break ; if ( t . charAt ( i ) == s . charAt ( count ) ) count ++ ; } return count ; }
[]
null
[]
[]
python
code_translation
import sys def f_gold(A, B, m, n): A.sort() B.sort() a = 0 b = 0 result = sys.maxsize while (a < m and b < n): if (abs(A[a] - B[b]) < result): result = abs(A[a] - B[b]) if (A[a] < B[b]): a += 1 else: b += 1 return result
java
[ [ "[2, 2, 11, 13, 18, 18, 23, 25, 28, 28, 37, 39, 53, 56, 67, 70, 74, 74, 75, 79, 80, 82, 84, 89, 94, 95, 95, 98, 98], [5, 6, 11, 13, 13, 16, 17, 19, 23, 25, 28, 31, 31, 39, 41, 44, 45, 52, 62, 64, 70, 71, 73, 78, 78, 79, 85, 86, 92], 28, 14", "0" ], [ "[-94, -78, -78, -72, -72, -72, -70, -70, -64, ...
f_gold
SMALLEST_DIFFERENCE_PAIR_VALUES_TWO_UNSORTED_ARRAYS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class SMALLEST_DIFFERENCE_PAIR_VALUES_TWO_UNSORTED_ARRAYS{ static int f_gold ( int A [ ] , int B [ ] , int m , int n ) { Arrays . sort ( A ) ; Arrays . sort ( B ) ; int a = 0 , b = 0 ; int result = Integer . MAX_VALUE ; while ( a < m && b < n ) { if ( Math . abs ( A [ a ] - B [ b ] ) < result ) result = Math . abs ( A [ a ] - B [ b ] ) ; if ( A [ a ] < B [ b ] ) a ++ ; else b ++ ; } return result ; }
[ "import sys" ]
null
[]
[]
python
code_translation
def f_gold ( n ) : return ( not ( n & 1 ) )
java
[ [ "57", "False" ], [ "73", "False" ], [ "79", "False" ], [ "36", "True" ], [ "71", "False" ], [ "23", "False" ], [ "41", "False" ], [ "66", "True" ], [ "46", "True" ], [ "50", "True" ] ]
f_gold
CHECK_WHETHER_GIVEN_NUMBER_EVEN_ODD_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class CHECK_WHETHER_GIVEN_NUMBER_EVEN_ODD_1{ public static boolean f_gold ( int n ) { if ( ( n & 1 ) == 0 ) return true ; else return false ; }
[]
null
[]
[]
python
code_translation
def f_gold ( a , b , n ) : a.sort ( reverse = False ) b.sort ( reverse = False ) result = 0 for i in range ( 0 , n , 1 ) : if ( a [ i ] > b [ i ] ) : result = result + abs ( a [ i ] - b [ i ] ) elif ( a [ i ] < b [ i ] ) : result = result + abs ( a [ i ] - b [ i ] ) return result
java
[ [ "[1, 6, 6, 7, 10, 11, 13, 18, 19, 19, 19, 31, 34, 37, 37, 40, 41, 41, 47, 47, 53, 54, 55, 55, 56, 56, 60, 60, 62, 62, 66, 73, 75, 76, 78, 81, 81, 85, 88, 90, 91, 92, 93, 95, 97, 98], [2, 2, 4, 7, 8, 8, 8, 8, 8, 9, 9, 12, 15, 16, 21, 25, 26, 27, 29, 34, 34, 35, 38, 40, 40, 44, 44, 47, 48, 54, 58, 61, 63, 64, 6...
f_gold
MAKING_ELEMENTS_OF_TWO_ARRAYS_SAME_WITH_MINIMUM_INCREMENTDECREMENT
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MAKING_ELEMENTS_OF_TWO_ARRAYS_SAME_WITH_MINIMUM_INCREMENTDECREMENT{ static int f_gold ( int a [ ] , int b [ ] , int n ) { Arrays . sort ( a ) ; Arrays . sort ( b ) ; int result = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( a [ i ] > b [ i ] ) result = result + Math . abs ( a [ i ] - b [ i ] ) ; else if ( a [ i ] < b [ i ] ) result = result + Math . abs ( a [ i ] - b [ i ] ) ; } return result ; }
[]
null
[]
[]
python
code_translation
def f_gold ( num , divisor ) : while ( num >= divisor ) : num -= divisor ; return num ;
java
[ [ "70, 13", "5" ], [ "77, 3", "2" ], [ "77, 73", "4" ], [ "88, 54", "34" ], [ "96, 39", "18" ], [ "6, 10", "6" ], [ "79, 95", "79" ], [ "44, 32", "12" ], [ "26, 86", "26" ], [ "82, 91", "82" ] ]
f_gold
PROGRAM_TO_FIND_REMAINDER_WITHOUT_USING_MODULO_OR_OPERATOR_2
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_2{ static int f_gold ( int num , int divisor ) { while ( num >= divisor ) num -= divisor ; return num ; }
[]
null
[]
[]
python
code_translation
def f_gold ( arr , n ) : arr.sort ( ) return ( arr [ n - 1 ] + arr [ n - 2 ] + arr [ n - 3 ] )
java
[ [ "[6, 8, 18, 18, 27, 33, 33, 38, 42, 43, 44, 47, 52, 58, 64, 65, 67, 68, 71, 75, 85, 89, 91, 94, 94, 95, 95], 26", "283" ], [ "[-88, -84, -82, -58, -12, 18, 24, 24, 28, 30, 34, 44, 92, 94], 8", "66" ], [ "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1], 15", "2" ], ...
f_gold
MAXIMUM_TRIPLET_SUM_ARRAY_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MAXIMUM_TRIPLET_SUM_ARRAY_1{ static int f_gold ( int arr [ ] , int n ) { Arrays . sort ( arr ) ; return arr [ n - 1 ] + arr [ n - 2 ] + arr [ n - 3 ] ; }
[]
null
[]
[]
python
code_translation
def f_gold ( arr , n ) : ans = 0 for i in range ( 0 , n ) : for j in range ( i + 1 , n ) : if ( arr [ i ] == arr [ j ] ) : ans += 1 return ans
java
[ [ "[4, 6, 9, 16, 16, 21, 36, 41, 58, 60, 62, 73, 77, 81, 95], 12", "1" ], [ "[-86, -72, -26, -34, 18, -62, -66], 3", "0" ], [ "[1], 0", "0" ], [ "[16], 0", "0" ], [ "[-88, -80, -72, -68, -64, -26, 4, 14, 16, 22, 30, 32, 60, 74, 82], 11", "0" ], [ "[0, ...
f_gold
COUNT_INDEX_PAIRS_EQUAL_ELEMENTS_ARRAY
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class COUNT_INDEX_PAIRS_EQUAL_ELEMENTS_ARRAY{ static int f_gold ( int arr [ ] , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( arr [ i ] == arr [ j ] ) ans ++ ; return ans ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n , m , k ) : if ( m <= n - k + 1 ) : return m + k - 1 m = m - ( n - k + 1 ) if ( m % n == 0 ) : return n else : return m % n
java
[ [ "19, 14, 34", "9" ], [ "23, 51, 5", "9" ], [ "92, 10, 24", "33" ], [ "9, 50, 34", "2" ], [ "20, 67, 20", "6" ], [ "68, 25, 40", "64" ], [ "66, 30, 24", "53" ], [ "77, 22, 32", "53" ], [ "90, 1, 71", "71" ], ...
f_gold
DISTRIBUTING_M_ITEMS_CIRCLE_SIZE_N_STARTING_K_TH_POSITION
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class DISTRIBUTING_M_ITEMS_CIRCLE_SIZE_N_STARTING_K_TH_POSITION{ static int f_gold ( int n , int m , int k ) { if ( m <= n - k + 1 ) return m + k - 1 ; m = m - ( n - k + 1 ) ; return ( m % n == 0 ) ? n : ( m % n ) ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : if ( n == 0 ) : return 1 return n * f_gold ( n - 1 )
java
[ [ "77", "145183092028285869634070784086308284983740379224208358846781574688061991349156420080065207861248000000000000000000" ], [ "62", "31469973260387937525653122354950764088012280797258232192163168247821107200000000000000" ], [ "42", "14050061177528798985431426062445115699363840000...
f_gold
TAIL_RECURSION
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class TAIL_RECURSION{ static int f_gold ( int n ) { if ( n == 0 ) return 1 ; return n * f_gold ( n - 1 ) ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n , d ) : return ( n & ( d - 1 ) )
java
[ [ "54, 59", "50" ], [ "39, 84", "3" ], [ "35, 81", "0" ], [ "9, 60", "9" ], [ "62, 68", "2" ], [ "16, 16", "0" ], [ "93, 96", "93" ], [ "32, 38", "32" ], [ "39, 62", "37" ], [ "63, 16", "15" ] ]
f_gold
COMPUTE_MODULUS_DIVISION_BY_A_POWER_OF_2_NUMBER
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class COMPUTE_MODULUS_DIVISION_BY_A_POWER_OF_2_NUMBER{ static int f_gold ( int n , int d ) { return ( n & ( d - 1 ) ) ; }
[]
null
[]
[]
python
code_translation
def f_gold ( a , b , c ) : x = a - b y = b - c z = a - c if x * y > 0 : return b elif ( x * z > 0 ) : return else : return a
java
[ [ "48, 46, 38", "46" ], [ "21, 7, 16", "None" ], [ "71, 4, 31", "None" ], [ "93, 34, 11", "34" ], [ "3, 61, 32", "None" ], [ "58, 78, 6", "58" ], [ "88, 41, 66", "None" ], [ "8, 84, 38", "None" ], [ "17, 66, 27", ...
f_gold
MIDDLE_OF_THREE_USING_MINIMUM_COMPARISONS_2
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MIDDLE_OF_THREE_USING_MINIMUM_COMPARISONS_2{ public static int f_gold ( int a , int b , int c ) { int x = a - b ; int y = b - c ; int z = a - c ; if ( x * y > 0 ) return b ; else if ( x * z > 0 ) return c ; else return a ; }
[]
null
[]
[]
python
code_translation
def f_gold ( arr , N ) : lis = [ 0 ] * N for i in range ( N ) : lis [ i ] = 1 for i in range ( 1 , N ) : for j in range ( i ) : if ( arr [ i ] >= arr [ j ] and lis [ i ] < lis [ j ] + 1 ) : lis [ i ] = lis [ j ] + 1 max = 0 for i in range ( N ) : if ( max < lis [ i ] ) : max = lis [ i ] return ( N - max )
java
[ [ "[4, 7, 20, 22, 23, 31, 33, 36, 47, 61, 63, 63, 71, 74, 82, 91, 95, 99], 15", "0" ], [ "[-84, 12, -42, -78, 22, 72, 56, 70, 28, -72], 7", "3" ], [ "[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], 16", "0" ], [ "[29, 41, 4, 6...
f_gold
MINIMUM_INSERTIONS_SORT_ARRAY
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MINIMUM_INSERTIONS_SORT_ARRAY{ static int f_gold ( int arr [ ] , int N ) { int [ ] lis = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) lis [ i ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) for ( int j = 0 ; j < i ; j ++ ) if ( arr [ i ] >= arr [ j ] && lis [ i ] < lis [ j ] + 1 ) lis [ i ] = lis [ j ] + 1 ; int max = 0 ; for ( int i = 0 ; i < N ; i ++ ) if ( max < lis [ i ] ) max = lis [ i ] ; return ( N - max ) ; }
[]
null
[]
[]
python
code_translation
import sys def f_gold ( str1 ) : n = len ( str1 ) ; C = [ 0 ] * ( n + 1 ) ; P = [ [ False for x in range ( n + 1 ) ] for y in range ( n + 1 ) ] ; for i in range ( n ) : P [ i ] [ i ] = True ; for L in range ( 2 , n + 1 ) : for i in range ( n - L + 1 ) : j = i + L - 1 ; if ( L == 2 ) : P [ i ] [ j ] = ( str1 [ i ] == str1 [ j ] ) ; else : P [ i ] [ j ] = ( ( str1 [ i ] == str1 [ j ] ) and P [ i + 1 ] [ j - 1 ] ) ; for i in range ( n ) : if ( P [ 0 ] [ i ] == True ) : C [ i ] = 0 ; else : C [ i ] = sys.maxsize ; for j in range ( i ) : if ( P [ j + 1 ] [ i ] == True and 1 + C [ j ] < C [ i ] ) : C [ i ] = 1 + C [ j ] ; return C [ n - 1 ] ;
java
[ [ "'YYGWgYrovdsh'", "10" ], [ "'56109778'", "6" ], [ "'101'", "0" ], [ "'RxM'", "2" ], [ "'187546405'", "6" ], [ "'0110010'", "1" ], [ "'wVODAmgvI'", "8" ], [ "'56719'", "4" ], [ "'10100011001100'", "2" ], [ ...
f_gold
DYNAMIC_PROGRAMMING_SET_17_PALINDROME_PARTITIONING_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class DYNAMIC_PROGRAMMING_SET_17_PALINDROME_PARTITIONING_1{ static int f_gold ( String str ) { int n = str . length ( ) ; int [ ] C = new int [ n ] ; boolean [ ] [ ] P = new boolean [ n ] [ n ] ; int i , j , k , L ; for ( i = 0 ; i < n ; i ++ ) { P [ i ] [ i ] = true ; } for ( L = 2 ; L <= n ; L ++ ) { for ( i = 0 ; i < n - L + 1 ; i ++ ) { j = i + L - 1 ; if ( L == 2 ) P [ i ] [ j ] = ( str . charAt ( i ) == str . charAt ( j ) ) ; else P [ i ] [ j ] = ( str . charAt ( i ) == str . charAt ( j ) ) && P [ i + 1 ] [ j - 1 ] ; } } for ( i = 0 ; i < n ; i ++ ) { if ( P [ 0 ] [ i ] == true ) C [ i ] = 0 ; else { C [ i ] = Integer . MAX_VALUE ; for ( j = 0 ; j < i ; j ++ ) { if ( P [ j + 1 ] [ i ] == true && 1 + C [ j ] < C [ i ] ) C [ i ] = 1 + C [ j ] ; } } } return C [ n - 1 ] ; }
[ "import sys" ]
null
[]
[]
python
code_translation
def f_gold ( arr1 , arr2 , n ) : for i in range ( 0 , n ) : if ( arr1 [ i ] != arr2 [ i ] ) : return i return n
java
[ [ "[1, 6, 7, 10, 11, 12, 12, 16, 17, 29, 32, 33, 35, 35, 45, 49, 52, 56, 57, 58, 61, 62, 63, 64, 68, 71, 71, 77, 79, 79, 81, 82, 82, 83, 83, 89, 89, 93, 94, 94], [3, 12, 13, 14, 15, 17, 18, 19, 22, 24, 28, 29, 33, 37, 41, 42, 44, 49, 51, 51, 52, 53, 56, 56, 59, 60, 64, 64, 67, 70, 71, 78, 83, 88, 88, 90, 92, 93...
f_gold
FIND_INDEX_OF_AN_EXTRA_ELEMENT_PRESENT_IN_ONE_SORTED_ARRAY
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_INDEX_OF_AN_EXTRA_ELEMENT_PRESENT_IN_ONE_SORTED_ARRAY{ static int f_gold ( int arr1 [ ] , int arr2 [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) if ( arr1 [ i ] != arr2 [ i ] ) return i ; return n ; }
[]
null
[]
[]
python
code_translation
def f_gold ( arr , n ) : res = 0 for i in range ( 0 , n - 1 ) : res = res ^ ( i + 1 ) ^ arr [ i ] res = res ^ arr [ n - 1 ] return res
java
[ [ "[2, 2, 4, 5, 5, 7, 7, 7, 8, 11, 14, 15, 18, 19, 20, 25, 25, 29, 29, 31, 32, 32, 33, 38, 42, 48, 52, 55, 60, 61, 63, 71, 74, 78, 82, 82, 84, 84, 87, 87, 88, 90, 93, 94, 94], 31", "52" ], [ "[46, 2, 62, 60, 92, 4, 26, 66, 66, 90, 26, -14, 76, -20, -68], 8", "46" ], [ "[0, 0, 0, 1, 1, 1,...
f_gold
FIND_REPETITIVE_ELEMENT_1_N_1_2
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_REPETITIVE_ELEMENT_1_N_1_2{ static int f_gold ( int arr [ ] , int n ) { int res = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) res = res ^ ( i + 1 ) ^ arr [ i ] ; res = res ^ arr [ n - 1 ] ; return res ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : if ( n == 0 ) : return "0" ; bin = "" ; while ( n > 0 ) : if ( n & 1 == 0 ) : bin = '0' + bin ; else : bin = '1' + bin ; n = n >> 1 ; return bin ;
java
[ [ "35", "'100011'" ], [ "17", "'10001'" ], [ "8", "'1000'" ], [ "99", "'1100011'" ], [ "57", "'111001'" ], [ "39", "'100111'" ], [ "99", "'1100011'" ], [ "14", "'1110'" ], [ "22", "'10110'" ], [ "7", ...
f_gold
DECIMAL_BINARY_CONVERSION_WITHOUT_USING_ARITHMETIC_OPERATORS
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class DECIMAL_BINARY_CONVERSION_WITHOUT_USING_ARITHMETIC_OPERATORS{ static String f_gold ( int n ) { if ( n == 0 ) return "0" ; String bin = "" ; while ( n > 0 ) { bin = ( ( n & 1 ) == 0 ? '0' : '1' ) + bin ; n >>= 1 ; } return bin ; }
[]
null
[]
[]
python
code_translation
def f_gold ( str ) : zeros = 0 ones = 0 for i in range ( 0 , len ( str ) ) : ch = str [ i ] ; if ( ch == '0' ) : zeros = zeros + 1 else : ones = ones + 1 return ( zeros == 1 or ones == 1 ) ;
java
[ [ "'00001'", "True" ], [ "'0000'", "False" ], [ "'11'", "False" ], [ "'111110'", "True" ], [ "'1'", "True" ], [ "'111010111010'", "False" ], [ "'hUInqJXNdbfP'", "False" ], [ "'5191'", "False" ], [ "'1110101101'", ...
f_gold
CHANGE_BITS_CAN_MADE_ONE_FLIP
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class CHANGE_BITS_CAN_MADE_ONE_FLIP{ static boolean f_gold ( String str ) { int zeros = 0 , ones = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { char ch = str . charAt ( i ) ; if ( ch == '0' ) ++ zeros ; else ++ ones ; } return ( zeros == 1 || ones == 1 ) ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : position = 1 m = 1 while ( not ( n & m ) ) : m = m << 1 position += 1 return position
java
[ [ "17", "1" ], [ "97", "1" ], [ "73", "1" ], [ "68", "3" ], [ "6", "2" ], [ "84", "3" ], [ "72", "4" ], [ "66", "2" ], [ "57", "1" ], [ "11", "1" ] ]
f_gold
POSITION_OF_RIGHTMOST_SET_BIT_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class POSITION_OF_RIGHTMOST_SET_BIT_1{ static int f_gold ( int n ) { int position = 1 ; int m = 1 ; while ( ( n & m ) == 0 ) { m = m << 1 ; position ++ ; } return position ; }
[]
null
[]
[]
python
code_translation
def f_gold ( str ) : n = len ( str ) ; return int ( n * ( n + 1 ) / 2 ) ;
java
[ [ "'gZFGZsHCimLf'", "78" ], [ "'505357'", "21" ], [ "'011011101'", "45" ], [ "'ovfwP Osauz'", "66" ], [ "'92132238746026'", "105" ], [ "'01100'", "15" ], [ "'RaOWYQRfiWKSyC'", "105" ], [ "'861330202'", "45" ], [ "'00...
f_gold
NUMBER_SUBSTRINGS_STRING
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class NUMBER_SUBSTRINGS_STRING{ static int f_gold ( String str ) { int n = str . length ( ) ; return n * ( n + 1 ) / 2 ; }
[]
null
[]
[]
python
code_translation
def f_gold ( arr , n ) : leftMax = [ None ] * n leftMax [ 0 ] = float ( '-inf' ) for i in range ( 1 , n ) : leftMax [ i ] = max ( leftMax [ i - 1 ] , arr [ i - 1 ] ) rightMin = float ( 'inf' ) for i in range ( n - 1 , - 1 , - 1 ) : if leftMax [ i ] < arr [ i ] and rightMin > arr [ i ] : return i rightMin = min ( rightMin , arr [ i ] ) return - 1
java
[ [ "[4, 24, 30, 33, 56, 67, 87, 90], 4", "3" ], [ "[72, -48, 12, 4, 46, 36, 2, 58, 82, -88, -14, 56, 90, 76, 18, -6, -28, 18, 88, 90, 40, -68, -10, -82, -28, 16, 32, -90, 12, -86, -16, 78, -98, -52, -26, 80, 6, 50, 40, -12, 52, 38, -92, 94, -32, 14, -80, -88, 48], 28", "-1" ], [ "[0, 0, 0...
f_gold
FIND_THE_ELEMENT_BEFORE_WHICH_ALL_THE_ELEMENTS_ARE_SMALLER_THAN_IT_AND_AFTER_WHICH_ALL_ARE_GREATER_THAN_IT
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class FIND_THE_ELEMENT_BEFORE_WHICH_ALL_THE_ELEMENTS_ARE_SMALLER_THAN_IT_AND_AFTER_WHICH_ALL_ARE_GREATER_THAN_IT{ static int f_gold ( int [ ] arr , int n ) { int [ ] leftMax = new int [ n ] ; leftMax [ 0 ] = Integer . MIN_VALUE ; for ( int i = 1 ; i < n ; i ++ ) leftMax [ i ] = Math . max ( leftMax [ i - 1 ] , arr [ i - 1 ] ) ; int rightMin = Integer . MAX_VALUE ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( leftMax [ i ] < arr [ i ] && rightMin > arr [ i ] ) return i ; rightMin = Math . min ( rightMin , arr [ i ] ) ; } return - 1 ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n ) : sum = 0 ; while ( n > 0 ) : sum += ( n % 10 ) ; n //= 10 ; if ( sum == 1 ) : return 10 ; return sum ;
java
[ [ "2", "2" ], [ "39", "12" ], [ "31", "4" ], [ "45", "9" ], [ "35", "8" ], [ "94", "13" ], [ "67", "13" ], [ "50", "5" ], [ "4", "4" ], [ "63", "9" ] ]
f_gold
MINIMIZE_THE_SUM_OF_DIGITS_OF_A_AND_B_SUCH_THAT_A_B_N
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MINIMIZE_THE_SUM_OF_DIGITS_OF_A_AND_B_SUCH_THAT_A_B_N{ static int f_gold ( int n ) { int sum = 0 ; while ( n > 0 ) { sum += ( n % 10 ) ; n /= 10 ; } if ( sum == 1 ) return 10 ; return sum ; }
[]
null
[]
[]
python
code_translation
def f_gold ( n , m ) : dp = [ [ 0 for x in range ( m + 1 ) ] for y in range ( n + 1 ) ] for i in range ( 1 , n + 1 ) : for j in range ( 0 , m + 1 ) : if ( i > j ) : if ( j == 0 ) : dp [ i ] [ j ] = 1 else : dp [ i ] [ j ] = ( ( ( i - j ) * dp [ i - 1 ] [ j - 1 ] ) + ( ( j + 1 ) * dp [ i - 1 ] [ j ] ) ) return dp [ n ] [ m ]
java
[ [ "27, 7", "940744845942385425654976" ], [ "77, 34", "6659628962352540071013461802622903732181448311622532437589102727552487005433977695399091580931215833915283931140" ], [ "35, 22", "35713299412878610033189961245712022360" ], [ "26, 20", "131921922645609200622" ], [ ...
f_gold
EULERIAN_NUMBER_1
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class EULERIAN_NUMBER_1{ public static int f_gold ( int n , int m ) { int [ ] [ ] dp = new int [ n + 1 ] [ m + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= m ; j ++ ) { if ( i > j ) { if ( j == 0 ) dp [ i ] [ j ] = 1 ; else dp [ i ] [ j ] = ( ( i - j ) * dp [ i - 1 ] [ j - 1 ] ) + ( ( j + 1 ) * dp [ i - 1 ] [ j ] ) ; } } } return dp [ n ] [ m ] ; }
[]
null
[]
[]
python
code_translation
def f_gold ( arr , n , k ) : count = 0 for i in range ( 0 , n ) : if ( arr [ i ] <= k ) : count = count + 1 bad = 0 for i in range ( 0 , count ) : if ( arr [ i ] > k ) : bad = bad + 1 ans = bad j = count for i in range ( 0 , n ) : if ( j == n ) : break if ( arr [ i ] > k ) : bad = bad - 1 if ( arr [ j ] > k ) : bad = bad + 1 ans = min ( ans , bad ) j = j + 1 return ans
java
[ [ "[7, 12, 15, 30, 33, 34, 53, 66, 73, 74, 76, 77, 85, 90], 9, 8", "0" ], [ "[-62, -20, -26, -24, 92, 66, -74, -4, 18, -82, -36, 92, -4, 92, -80, 56, -24, 4, -48, -10, -14, -46, -16, -58, -58, -6, -68, -22, -82, -16, 76, -30, -86, -38, -66, 28, 58, 30, -44, -56], 24, 28", "4" ], [ "[0, 0...
f_gold
MINIMUM_SWAPS_REQUIRED_BRING_ELEMENTS_LESS_EQUAL_K_TOGETHER
transcoder-geeksforgeeks
import java.util. *; import java.util.stream.*; import java.lang.*; import javafx.util.Pair; public class MINIMUM_SWAPS_REQUIRED_BRING_ELEMENTS_LESS_EQUAL_K_TOGETHER{ static int f_gold ( int arr [ ] , int n , int k ) { int count = 0 ; for ( int i = 0 ; i < n ; ++ i ) if ( arr [ i ] <= k ) ++ count ; int bad = 0 ; for ( int i = 0 ; i < count ; ++ i ) if ( arr [ i ] > k ) ++ bad ; int ans = bad ; for ( int i = 0 , j = count ; j < n ; ++ i , ++ j ) { if ( arr [ i ] > k ) -- bad ; if ( arr [ j ] > k ) ++ bad ; ans = Math . min ( ans , bad ) ; } return ans ; }
[]