python_code
stringlengths
0
4.04M
repo_name
stringlengths
8
58
file_path
stringlengths
5
147
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( base ) : base = ( base - 2 ) base = base / 2 return base * ( base + 1 ) / 2 #TOFILL if __name__ == '...
CodeGen-main
data/transcoder_evaluation_gfg/python/MAXIMUM_NUMBER_2X2_SQUARES_CAN_FIT_INSIDE_RIGHT_ISOSCELES_TRIANGLE.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n ) : return ( 1 << n ) ; #TOFILL if __name__ == '__main__': param = [ (48,), (42,), (15,), ...
CodeGen-main
data/transcoder_evaluation_gfg/python/SUM_BINOMIAL_COEFFICIENTS_1.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( p , q ) : dp = [ 1 for i in range ( q ) ] for i in range ( p - 1 ) : for j in range ( 1 , q ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/COUNT_POSSIBLE_PATHS_TOP_LEFT_BOTTOM_RIGHT_NXM_MATRIX_2.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n , k ) : um , curr_rem , maxSum = { } , 0 , 0 sm = [ 0 ] * n sm [ 0 ] = arr [ 0 ] for i in r...
CodeGen-main
data/transcoder_evaluation_gfg/python/MAXIMUM_NUMBER_CHOCOLATES_DISTRIBUTED_EQUALLY_AMONG_K_STUDENTS.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n ) : odd_count = 0 even_count = 0 if ( n < 0 ) : n = - n if ( n == 0 ) : return 1 ...
CodeGen-main
data/transcoder_evaluation_gfg/python/WRITE_AN_EFFICIENT_METHOD_TO_CHECK_IF_A_NUMBER_IS_MULTIPLE_OF_3.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n ) : dp = [ 0 for _ in range ( n + 1 ) ] for i in range ( 1 , n + 1 ) : if i <= 3 : dp...
CodeGen-main
data/transcoder_evaluation_gfg/python/COUNT_NUMBER_OF_WAYS_TO_FILL_A_N_X_4_GRID_USING_1_X_4_TILES.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold(str1, str2, k): if ((len(str1) + len(str2)) < k): return True commonLength = 0 for i in range(0, ...
CodeGen-main
data/transcoder_evaluation_gfg/python/CONVERTING_ONE_STRING_USING_APPEND_DELETE_LAST_OPERATIONS.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( set , n ) : if ( n <= 2 ) : return n L = [ [ 0 for x in range ( n ) ] for y in range ( n ) ] ll...
CodeGen-main
data/transcoder_evaluation_gfg/python/LENGTH_OF_THE_LONGEST_ARITHMATIC_PROGRESSION_IN_A_SORTED_ARRAY.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n ) : index = 0 while index < n : if index == 0 : index = index + 1 if ar...
CodeGen-main
data/transcoder_evaluation_gfg/python/GNOME_SORT_A_STUPID_ONE.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , N , k ) : maxSum = 0 ; arr.sort ( ) ; i = N - 1 ; while ( i >= 0 ) : if ( arr [ i ] -...
CodeGen-main
data/transcoder_evaluation_gfg/python/MAXIMUM_SUM_PAIRS_SPECIFIC_DIFFERENCE_1.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n ) : temp = [ 0 ] * n for i in range ( n ) : temp [ i ] = arr [ i ] temp.sort ( ) fo...
CodeGen-main
data/transcoder_evaluation_gfg/python/CHECK_REVERSING_SUB_ARRAY_MAKE_ARRAY_SORTED.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n ) : if ( n == 0 ) : return False while ( n != 1 ) : if ( n % 4 != 0 ) : retur...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_WHETHER_A_GIVEN_NUMBER_IS_A_POWER_OF_4_OR_NOT.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( array , m , n ) : counter = 0 for i in range ( 0 , m ) : for j in range ( 0 , n ) : if ...
CodeGen-main
data/transcoder_evaluation_gfg/python/CHECK_GIVEN_MATRIX_SPARSE_NOT.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import math def f_gold ( n ) : if ( n < 10 ) : return ( n * ( n + 1 ) / 2 ) d = ( int ) ( math.log10 ( n ) ) ...
CodeGen-main
data/transcoder_evaluation_gfg/python/COUNT_SUM_OF_DIGITS_IN_NUMBERS_FROM_1_TO_N.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n ) : dp = [ [ 0 ] * ( n + 1 ) for i in range ( 2 ) ] dp [ 0 ] [ 1 ] = 1 dp [ 1 ] [ 1 ] = 2 for i i...
CodeGen-main
data/transcoder_evaluation_gfg/python/COUNT_WAYS_BUILD_STREET_GIVEN_CONSTRAINTS.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( N ) : dp = [ 0 for i in range ( N ) ] dp [ 0 ] = 1 dp [ 1 ] = 2 i = 1 while dp [ i ] <= N : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/MAXIMUM_GAMES_PLAYED_WINNER.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n ) : return ( 3 * n * n - n ) / 2 #TOFILL if __name__ == '__main__': param = [ (96,), (93,), ...
CodeGen-main
data/transcoder_evaluation_gfg/python/NTH_PENTAGONAL_NUMBER.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( a , b ) : return ( a // 2 ) + ( b // 2 ) + ( ( a % 2 + b % 2 ) // 2 ) #TOFILL if __name__ == '__main__': ...
CodeGen-main
data/transcoder_evaluation_gfg/python/COMPUTE_AVERAGE_TWO_NUMBERS_WITHOUT_OVERFLOW_1.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n ) : arr.sort ( ) max_count = 1 ; res = arr [ 0 ] ; curr_count = 1 for i in range ( 1 , n ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/FREQUENT_ELEMENT_ARRAY.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n ) : arr.sort ( reverse = True ) dimension = [ 0 , 0 ] i = 0 j = 0 while ( i < n - 1 and...
CodeGen-main
data/transcoder_evaluation_gfg/python/MAXIMUM_AREA_RECTANGLE_PICKING_FOUR_SIDES_ARRAY.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( a , n , k ) : if k >= n - 1 : return n best = 0 times = 0 for i in range ( n ) : if...
CodeGen-main
data/transcoder_evaluation_gfg/python/ARRAY_ELEMENT_MOVED_K_USING_SINGLE_MOVES.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n ) : result = 0 for i in range ( n + 1 ) : for j in range ( n + 1 ) : for k in range (...
CodeGen-main
data/transcoder_evaluation_gfg/python/NUMBER_NON_NEGATIVE_INTEGRAL_SOLUTIONS_B_C_N.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold(a, b): count = 0 p = abs(a * b) if (p == 0): return 1 while (p > 0): count = count + ...
CodeGen-main
data/transcoder_evaluation_gfg/python/NUMBER_DIGITS_PRODUCT_TWO_NUMBERS.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n , m ) : if ( n > m ) : return True DP = [ False for i in range ( m ) ] for i in range (...
CodeGen-main
data/transcoder_evaluation_gfg/python/SUBSET_SUM_DIVISIBLE_M.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( N , K ) : ans = 0 ; y = N / K ; x = N % K ; ans = ( ( K * ( K - 1 ) / 2 ) * y + ( x * ( x + 1 ) ) /...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_SUM_MODULO_K_FIRST_N_NATURAL_NUMBER_1.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n ) : res = 0 m = dict ( ) for i in range ( n ) : Sum = 0 for j in range ( i , n ...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_SUM_UNIQUE_SUB_ARRAY_SUM_GIVEN_ARRAY.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr1 , arr2 , m , n , k ) : sorted1 = [ 0 ] * ( m + n ) i = 0 j = 0 d = 0 while ( i < m and j <...
CodeGen-main
data/transcoder_evaluation_gfg/python/K_TH_ELEMENT_TWO_SORTED_ARRAYS.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( ar1 , ar2 , n ) : i = 0 j = 0 m1 = - 1 m2 = - 1 count = 0 while count < n + 1 : cou...
CodeGen-main
data/transcoder_evaluation_gfg/python/MEDIAN_OF_TWO_SORTED_ARRAYS.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n , k ) : count = 0 arr.sort ( ) l = 0 r = 0 while r < n : if arr [ r ] - arr [ l...
CodeGen-main
data/transcoder_evaluation_gfg/python/COUNT_PAIRS_DIFFERENCE_EQUAL_K_1.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n ) : for i in range ( 0 , n , 2 ) : if ( i > 0 and arr [ i ] < arr [ i - 1 ] ) : arr...
CodeGen-main
data/transcoder_evaluation_gfg/python/SORT_ARRAY_WAVE_FORM_2_1.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( a , b ) : res = 0 while ( b > 0 ) : if ( b & 1 ) : res = res + a a = a << 1 ...
CodeGen-main
data/transcoder_evaluation_gfg/python/FAST_MULTIPLICATION_METHOD_WITHOUT_USING_MULTIPLICATION_OPERATOR_RUSSIAN_PEASANTS_ALGORITHM.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( mat , N ) : for row in range ( N ) : for col in range ( N ) : if ( row == col and mat [ row...
CodeGen-main
data/transcoder_evaluation_gfg/python/PROGRAM_PRINT_IDENTITY_MATRIX_1.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import math def f_gold ( x ) : temp = x n = 0 while ( x != 0 ) : x = x // 10 n = n + 1 x = temp...
CodeGen-main
data/transcoder_evaluation_gfg/python/PROGRAM_CHECK_PLUS_PERFECT_NUMBER.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import math def f_gold ( n ) : l = math.sqrt ( n ) sq = l * l if ( sq == n ) : return l * 4 else : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/MINIMUM_PERIMETER_N_BLOCKS.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( a ) : return ( 4 * a ) #TOFILL if __name__ == '__main__': param = [ (98,), (9,), (18,), ...
CodeGen-main
data/transcoder_evaluation_gfg/python/PYTHON_PROGRAM_FIND_PERIMETER_CIRCUMFERENCE_SQUARE_RECTANGLE.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n , r , p ) : C = [ 0 for i in range ( r + 1 ) ] C [ 0 ] = 1 for i in range ( 1 , n + 1 ) : for...
CodeGen-main
data/transcoder_evaluation_gfg/python/COMPUTE_NCR_P_SET_1_INTRODUCTION_AND_DYNAMIC_PROGRAMMING_SOLUTION.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , N , K ) : arr.sort ( ) res = 2147483647 for i in range ( ( N - K ) + 1 ) : curSeqDiff = a...
CodeGen-main
data/transcoder_evaluation_gfg/python/MINIMUM_DIFFERENCE_MAX_MIN_K_SIZE_SUBSETS.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( a , b , n ) : a.sort ( reverse = False ) b.sort ( reverse = False ) result = 0 for i in range ( 0 ,...
CodeGen-main
data/transcoder_evaluation_gfg/python/MAKING_ELEMENTS_OF_TWO_ARRAYS_SAME_WITH_MINIMUM_INCREMENTDECREMENT.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n ) : x = n y = 1 e = 0.000001 while ( x - y > e ) : x = ( x + y ) / 2 y = n / x ...
CodeGen-main
data/transcoder_evaluation_gfg/python/SQUARE_ROOT_OF_A_PERFECT_SQUARE.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , i , n ) : if i > int ( ( n - 2 ) / 2 ) : return True if ( arr [ i ] >= arr [ 2 * i + 1 ] and ...
CodeGen-main
data/transcoder_evaluation_gfg/python/HOW_TO_CHECK_IF_A_GIVEN_ARRAY_REPRESENTS_A_BINARY_HEAP.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import math def f_gold(r1, r2, r3): return 1.33 * math.pi * r1 * r2 * r3 #TOFILL if __name__ == '__main__': param =...
CodeGen-main
data/transcoder_evaluation_gfg/python/PROGRAM_CALCULATE_VOLUME_ELLIPSOID.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr1 , arr2 , m , n , x ) : count = 0 us = set ( ) for i in range ( m ) : us.add ( arr1 [ i ] )...
CodeGen-main
data/transcoder_evaluation_gfg/python/COUNT_PAIRS_TWO_SORTED_ARRAYS_WHOSE_SUM_EQUAL_GIVEN_VALUE_X_1.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( A , B , C , M ) : res = pow ( B , C , M - 1 ) ans = pow ( A , res , M ) return ans #TOFILL if __name...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_POWER_POWER_MOD_PRIME.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n ) : if n <= 1 : return f_gold ( arr , n - 1 ) last = arr [ n - 1 ] j = n - 2 wh...
CodeGen-main
data/transcoder_evaluation_gfg/python/RECURSIVE_INSERTION_SORT.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n ) : arr.sort ( ) ; min_xor = 999999 val = 0 for i in range ( 0 , n - 1 ) : for j in...
CodeGen-main
data/transcoder_evaluation_gfg/python/MINIMUM_XOR_VALUE_PAIR.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( str ) : tmp = str + str n = len ( str ) for i in range ( 1 , n + 1 ) : substring = tmp [ i : n ...
CodeGen-main
data/transcoder_evaluation_gfg/python/MINIMUM_ROTATIONS_REQUIRED_GET_STRING.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( m , n , a ) : val = 1 k , l = 0 , 0 while ( k < m and l < n ) : for i in range ( l , n ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/CIRCULAR_MATRIX_CONSTRUCT_A_MATRIX_WITH_NUMBERS_1_TO_MN_IN_SPIRAL_WAY.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import heapq def f_gold ( arr , n , k ) : sum = [ ] sum.append ( 0 ) sum.append ( arr [ 0 ] ) for i in range ( ...
CodeGen-main
data/transcoder_evaluation_gfg/python/K_TH_LARGEST_SUM_CONTIGUOUS_SUBARRAY.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n ) : return 1 if ( n == 1 or n == 0 ) else n * f_gold ( n - 1 ) ; #TOFILL if __name__ == '__main__': pa...
CodeGen-main
data/transcoder_evaluation_gfg/python/C_PROGRAM_FACTORIAL_NUMBER_1.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( s ) : result = 0 ; n = len ( s ) ; for i in range ( n ) : for j in range ( i , n ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/COUNT_SUBSTRINGS_WITH_SAME_FIRST_AND_LAST_CHARACTERS.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import math def f_gold ( n ) : count = 0 if ( n % 2 == 0 ) : count = count + 1 while ( n % 2 == 0 ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/HARDY_RAMANUJAN_THEOREM.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n , x ) : i = 0 for i in range ( i , n ) : if ( arr [ i ] == x ) : return i r...
CodeGen-main
data/transcoder_evaluation_gfg/python/ANALYSIS_OF_ALGORITHMS_SET_2_ASYMPTOTIC_ANALYSIS.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n ) : return ( int ) ( 0.6172 * ( pow ( 10 , n ) - 1 ) - 0.55 * n ) #TOFILL if __name__ == '__main__': p...
CodeGen-main
data/transcoder_evaluation_gfg/python/SUM_SERIES_555555_N_TERMS.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold(mat, N): max_xor = 0 for i in range(N): r_xor = 0 c_xor = 0 for j in range(N): ...
CodeGen-main
data/transcoder_evaluation_gfg/python/MAXIMUM_XOR_VALUE_MATRIX.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n ) : result = 0 ; for i in range ( 0 , n ) : for j in range ( i + 1 , n ) : prod...
CodeGen-main
data/transcoder_evaluation_gfg/python/COUNT_PAIRS_WHOSE_PRODUCTS_EXIST_IN_ARRAY.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n ) : pPrevPrev , pPrev , pCurr , pNext = 1 , 1 , 1 , 1 for i in range ( 3 , n + 1 ) : pNext = pPre...
CodeGen-main
data/transcoder_evaluation_gfg/python/PADOVAN_SEQUENCE.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import math def f_gold ( side ) : volume = ( side ** 3 / ( 6 * math.sqrt ( 2 ) ) ) return round ( volume , 2 ) #TOFIL...
CodeGen-main
data/transcoder_evaluation_gfg/python/CALCULATE_AREA_TETRAHEDRON.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( x ) : if ( x == 0 or x == 1 ) : return x i = 1 ; result = 1 while ( result <= x ) : i +...
CodeGen-main
data/transcoder_evaluation_gfg/python/SQUARE_ROOT_OF_AN_INTEGER.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( diameter , height ) : return 2 * ( diameter + height ) #TOFILL if __name__ == '__main__': param = [ ...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_PERIMETER_CYLINDER.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( x1 , y1 , x2 , y2 ) : return ( float ) ( y2 - y1 ) / ( x2 - x1 ) #TOFILL if __name__ == '__main__': para...
CodeGen-main
data/transcoder_evaluation_gfg/python/PROGRAM_FIND_SLOPE_LINE.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n ) : max_idx = n - 1 min_idx = 0 max_elem = arr [ n - 1 ] + 1 for i in range ( 0 , n ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/REARRANGE_ARRAY_MAXIMUM_MINIMUM_FORM_SET_2_O1_EXTRA_SPACE.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( k ) : return k * k * k #TOFILL if __name__ == '__main__': param = [ (57,), (96,), (14,), ...
CodeGen-main
data/transcoder_evaluation_gfg/python/SUM_K_TH_GROUP_ODD_POSITIVE_NUMBERS_1.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold(k): cur = int((k * (k - 1)) + 1) sum = 0 while k: sum += cur cur += 2 k = k - 1 ...
CodeGen-main
data/transcoder_evaluation_gfg/python/SUM_K_TH_GROUP_ODD_POSITIVE_NUMBERS.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n ) : ugly = [ 0 ] * n ugly [ 0 ] = 1 i2 = i3 = i5 = 0 next_multiple_of_2 = 2 next_multiple_of_...
CodeGen-main
data/transcoder_evaluation_gfg/python/UGLY_NUMBERS.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( tree , k ) : level = - 1 sum = 0 n = len ( tree ) for i in range ( n ) : if ( tree [ i ] ==...
CodeGen-main
data/transcoder_evaluation_gfg/python/SUM_NODES_K_TH_LEVEL_TREE_REPRESENTED_STRING.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import math def f_gold ( x , y ) : res1 = math.log ( y ) / math.log ( x ) ; res2 = math.log ( y ) / math.log ( x ) ; ...
CodeGen-main
data/transcoder_evaluation_gfg/python/CHECK_IF_A_NUMBER_IS_POWER_OF_ANOTHER_NUMBER_1.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n ) : max = 0 for i in range ( n ) : for j in range ( n ) : if ( ( j - 3 ) >= 0 )...
CodeGen-main
data/transcoder_evaluation_gfg/python/MAXIMUM_PRODUCT_OF_4_ADJACENT_ELEMENTS_IN_MATRIX.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( str , n ) : l = len ( str ) if ( l >= n ) : return True return False #TOFILL if __name__ == ...
CodeGen-main
data/transcoder_evaluation_gfg/python/CHECK_IF_STRING_REMAINS_PALINDROME_AFTER_REMOVING_GIVEN_NUMBER_OF_CHARACTERS.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( m , x , revenue , n , t ) : maxRev = [ 0 ] * ( m + 1 ) nxtbb = 0 ; for i in range ( 1 , m + 1 ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/HIGHWAY_BILLBOARD_PROBLEM.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( a , b ) : return ( ( 2 * a ) + ( 2 * b ) ) #TOFILL if __name__ == '__main__': param = [ (801.0366882...
CodeGen-main
data/transcoder_evaluation_gfg/python/PROGRAM_CIRCUMFERENCE_PARALLELOGRAM.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import math def f_gold ( num ) : if ( num < 0 ) : return False c = ( - 2 * num ) b , a = 1 , 1 d = ( b ...
CodeGen-main
data/transcoder_evaluation_gfg/python/TRIANGULAR_NUMBERS_1.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( a , b , n , m ) : countA = dict ( ) countB = dict ( ) for i in range ( n ) : countA [ a [ i ] ]...
CodeGen-main
data/transcoder_evaluation_gfg/python/REMOVE_MINIMUM_NUMBER_ELEMENTS_NO_COMMON_ELEMENT_EXIST_ARRAY.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import math def f_gold ( n ) : res = 1 while n % 2 == 0 : n = n // 2 for i in range ( 3 , int ( math.sqrt (...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_SUM_ODD_FACTORS_NUMBER.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n ) : res = list ( ) res.append ( 0 ) res.append ( 1 ) i = 2 while i < n + 1 : res.appe...
CodeGen-main
data/transcoder_evaluation_gfg/python/MAXIMUM_VALUE_CHOICE_EITHER_DIVIDING_CONSIDERING.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n ) : S = set ( ) ; for i in range ( n ) : S.add ( arr [ i ] ) ; ans = 0 ; for i in r...
CodeGen-main
data/transcoder_evaluation_gfg/python/MAXIMUM_CONSECUTIVE_NUMBERS_PRESENT_ARRAY.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( str ) : N = len ( str ) cps = [ [ 0 for i in range ( N + 2 ) ] for j in range ( N + 2 ) ] for i in rang...
CodeGen-main
data/transcoder_evaluation_gfg/python/COUNT_PALINDROMIC_SUBSEQUENCE_GIVEN_STRING.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( str , k ) : l = len ( str ) if ( k >= l ) : return 0 frequency = [ 0 ] * MAX_CHAR for i in ...
CodeGen-main
data/transcoder_evaluation_gfg/python/MINIMUM_SUM_SQUARES_CHARACTERS_COUNTS_GIVEN_STRING_REMOVING_K_CHARACTERS.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( array , start , end ) : if ( start > end ) : return end + 1 if ( start != array [ start ] ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_THE_FIRST_MISSING_NUMBER.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( x ) : return ( 3 * x * ( x + 1 ) ) / 2 #TOFILL if __name__ == '__main__': param = [ (6,), (25,),...
CodeGen-main
data/transcoder_evaluation_gfg/python/TRIANGULAR_MATCHSTICK_NUMBER.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n ) : count = 0 arr.sort ( ) for i in range ( 0 , n - 1 ) : if ( arr [ i ] != arr [ i + 1...
CodeGen-main
data/transcoder_evaluation_gfg/python/ELEMENTS_TO_BE_ADDED_SO_THAT_ALL_ELEMENTS_OF_A_RANGE_ARE_PRESENT_IN_ARRAY.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( str ) : for i in range ( 0 , len ( str ) ) : if ( str [ i ].istitle ( ) ) : return str [ i ...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIRST_UPPERCASE_LETTER_IN_A_STRING_ITERATIVE_AND_RECURSIVE.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( x , y ) : res = 1 for i in range ( y ) : res = ( res * x ) % 10 return res #TOFILL if __name...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_UNIT_DIGIT_X_RAISED_POWER_Y.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( m , n , a ) : k = 0 l = 0 stk = [ ] while ( k <= m and l <= n ) : for i in range ( l , n + ...
CodeGen-main
data/transcoder_evaluation_gfg/python/PRINT_MATRIX_ANTISPIRAL_FORM.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( a1 , a2 , a3 , n1 , n2 , n3 , sum ) : for i in range ( 0 , n1 ) : for j in range ( 0 , n2 ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_THREE_ELEMENT_FROM_DIFFERENT_THREE_ARRAYS_SUCH_THAT_THAT_A_B_C_K.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( num ) : length = len ( num ) if ( length == 1 and num [ 0 ] == '0' ) : return True if ( length ...
CodeGen-main
data/transcoder_evaluation_gfg/python/CHECK_LARGE_NUMBER_DIVISIBLE_13_NOT.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n ) : count = 0 while ( n ) : n &= ( n - 1 ) count += 1 return count #TOFILL if __na...
CodeGen-main
data/transcoder_evaluation_gfg/python/COUNT_SET_BITS_IN_AN_INTEGER_2.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n ) : result = 0 Hash = set ( ) for i in range ( n ) : Hash.add ( arr [ i ] ) for i i...
CodeGen-main
data/transcoder_evaluation_gfg/python/COUNT_PAIRS_WHOSE_PRODUCTS_EXIST_IN_ARRAY_1.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n ) : jumps = [ 0 for i in range ( n ) ] for i in range ( n - 2 , - 1 , - 1 ) : if ( arr [ i ...
CodeGen-main
data/transcoder_evaluation_gfg/python/MINIMUM_NUMBER_OF_JUMPS_TO_REACH_END_OF_A_GIVEN_ARRAY_2.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n ) : return n * ( n + 1 ) * ( n + 2 ) * ( 3 * n + 1 ) / 24 #TOFILL if __name__ == '__main__': param = [...
CodeGen-main
data/transcoder_evaluation_gfg/python/SUM_PAIRWISE_PRODUCTS_2.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # 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...
CodeGen-main
data/transcoder_evaluation_gfg/python/LONGEST_COMMON_SUBSTRING.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n , p ) : ans = 0 ; temp = p ; while ( temp <= n ) : ans += n / temp ; temp = temp * p ...
CodeGen-main
data/transcoder_evaluation_gfg/python/FINDING_POWER_PRIME_NUMBER_P_N.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n ) : um = { i : 0 for i in range ( 10 ) } sum = 0 maxLen = 0 for i in range ( n ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/LONGEST_SUBARRAY_COUNT_1S_ONE_COUNT_0S.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( mat , n ) : res = 0 for i in range ( n ) : if mat [ i ] [ i ] == mat [ i ] [ n - i - 1 ] : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/ROW_WISE_COMMON_ELEMENTS_TWO_DIAGONALS_SQUARE_MATRIX.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( process , need ) : minResources = 0 minResources = process * ( need - 1 ) + 1 return minResources #TO...
CodeGen-main
data/transcoder_evaluation_gfg/python/PROGRAM_FOR_DEADLOCK_FREE_CONDITION_IN_OPERATING_SYSTEM.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( a , n ) : if n == 1 : return a [ 0 ] max_neg = - 999999999999 count_neg = 0 count_zero = 0 ...
CodeGen-main
data/transcoder_evaluation_gfg/python/MAXIMUM_PRODUCT_SUBSET_ARRAY.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n ) : if ( n == 0 or n == 1 ) : return True for i in range ( 1 , n ) : if ( arr [ i -...
CodeGen-main
data/transcoder_evaluation_gfg/python/PROGRAM_CHECK_ARRAY_SORTED_NOT_ITERATIVE_RECURSIVE_1.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n ) : found = True for i in range ( 0 , n - 2 ) : for j in range ( i + 1 , n - 1 ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_TRIPLETS_ARRAY_WHOSE_SUM_EQUAL_ZERO.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n ) : remainder = 0 for i in range ( 0 , n ) : remainder = ( remainder + arr [ i ] ) % 3 ...
CodeGen-main
data/transcoder_evaluation_gfg/python/POSSIBLE_TO_MAKE_A_DIVISIBLE_BY_3_NUMBER_USING_ALL_DIGITS_IN_AN_ARRAY.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( ar , n ) : if ( n <= 4 ) : return min ( ar ) sum = [ 0 for i in range ( n ) ] sum [ 0 ] = ar [ ...
CodeGen-main
data/transcoder_evaluation_gfg/python/MINIMUM_SUM_SUBSEQUENCE_LEAST_ONE_EVERY_FOUR_CONSECUTIVE_ELEMENTS_PICKED_1.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n , k ) : if k > n : return - 1 csum = [ 0 ] * n csum [ 0 ] = arr [ 0 ] for i in rang...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_MAXIMUM_AVERAGE_SUBARRAY_OF_K_LENGTH.py