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 ( n ) : res = n for j in range ( len ( n ) - 1 , - 1 , - 1 ) : res += n [ j ] return res #TOFIL...
CodeGen-main
data/transcoder_evaluation_gfg/python/NTH_EVEN_LENGTH_PALINDROME.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 , x ) : table = [ [ 0 ] * ( x + 1 ) for i in range ( n + 1 ) ] for j in range ( 1 , min ( m + 1 , x +...
CodeGen-main
data/transcoder_evaluation_gfg/python/DICE_THROW_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 ( poly , n , x ) : result = poly [ 0 ] for i in range ( 1 , n ) : result = result * x + poly [ i ] ...
CodeGen-main
data/transcoder_evaluation_gfg/python/HORNERS_METHOD_POLYNOMIAL_EVALUATION.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 ) : A.sort ( ) #TOFILL if __name__ == '__main__': param = [ ([2, 3, 11, 13, 18, 24, 26, 30, 31...
CodeGen-main
data/transcoder_evaluation_gfg/python/SORT_ARRAY_TWO_HALVES_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 ( a , b , c , d ) : sum = a * a + b * b + c * c ; if ( d * d == sum ) : return True else : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/PYTHAGOREAN_QUADRUPLE.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 , arr_size ) : for i in range ( 0 , arr_size ) : count = 0 for j in range ( 0 , arr_size ) ...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_THE_NUMBER_OCCURRING_ODD_NUMBER_OF_TIMES.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 ) : sum = 0 for row in range ( n ) : sum = sum + ( 1 << row ) return sum #TOFILL if __name...
CodeGen-main
data/transcoder_evaluation_gfg/python/SUM_OF_ALL_ELEMENTS_UP_TO_NTH_ROW_IN_A_PASCALS_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 ( arr1 , arr2 , n ) : for i in range ( 0 , n ) : if ( arr1 [ i ] != arr2 [ i ] ) : return i ...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_INDEX_OF_AN_EXTRA_ELEMENT_PRESENT_IN_ONE_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 ) : ones = 0 twos = 0 for i in range ( n ) : twos = twos | ( ones & arr [ i ] ) ...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_THE_ELEMENT_THAT_APPEARS_ONCE.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 ( no ) : return 0 if no == 0 else int ( no % 10 ) + f_gold ( int ( no / 10 ) ) #TOFILL if __name__ == '__main_...
CodeGen-main
data/transcoder_evaluation_gfg/python/HOW_CAN_WE_SUM_THE_DIGITS_OF_A_GIVEN_NUMBER_IN_SINGLE_STATEMENT_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. # import sys def f_gold ( arr , n ) : min_ending_here = sys.maxsize min_so_far = sys.maxsize for i in range ( n ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/SMALLEST_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 ( text , s ) : result = "" for i in range ( len ( text ) ) : char = text [ i ] if ( char.isup...
CodeGen-main
data/transcoder_evaluation_gfg/python/CAESAR_CIPHER.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 ) : p = - 1 for i in range ( len ( s ) ) : for j in range ( i + 1 , len ( s ) ) : if ...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_REPEATED_CHARACTER_PRESENT_FIRST_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 ( arr , n ) : Hash = dict ( ) for i in range ( n ) : if arr [ i ] in Hash.keys ( ) : Hash...
CodeGen-main
data/transcoder_evaluation_gfg/python/FREQUENT_ELEMENT_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 ( n ) : return int ( ( ( n + 1 ) * ( n + 2 ) ) / 2 ) #TOFILL if __name__ == '__main__': param = [ (41,...
CodeGen-main
data/transcoder_evaluation_gfg/python/NUMBER_NON_NEGATIVE_INTEGRAL_SOLUTIONS_B_C_N_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 ( ar , m , n ) : even = 0 odd = 0 for i in range ( m ) : for j in range ( n ) : if ( ...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_FREQUENCY_EVEN_ODD_NUMBERS_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 ( start , end , arr ) : frequency = dict ( ) for i in range ( start , end + 1 ) : if arr [ i ] in fre...
CodeGen-main
data/transcoder_evaluation_gfg/python/ARRAY_RANGE_QUERIES_ELEMENTS_FREQUENCY_VALUE.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 ) : msis = [ None ] * n msds = [ None ] * n max_sum = 0 msis [ 0 ] = arr [ 0 ] for i in...
CodeGen-main
data/transcoder_evaluation_gfg/python/MAXIMUM_SUM_BITONIC_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 ( blockSize , m , processSize , n ) : allocation = [ - 1 ] * n for i in range ( n ) : wstIdx = - 1 ...
CodeGen-main
data/transcoder_evaluation_gfg/python/PROGRAM_WORST_FIT_ALGORITHM_MEMORY_MANAGEMENT.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__': para...
CodeGen-main
data/transcoder_evaluation_gfg/python/PROGRAM_FOR_FACTORIAL_OF_A_NUMBER_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 ( str ) : result = "" v = True for i in range ( len ( str ) ) : if ( str [ i ] == ' ' ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/STRING_CONTAINING_FIRST_LETTER_EVERY_WORD_GIVEN_STRING_SPACES.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 ) : hash_map = { } ; curr_sum = 0 ; max_len = 0 ; ending_index = - 1 ; for i in range (...
CodeGen-main
data/transcoder_evaluation_gfg/python/LARGEST_SUBARRAY_WITH_EQUAL_NUMBER_OF_0S_AND_1S_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 ( xp , yp ) : xp [ 0 ] = xp [ 0 ] ^ yp [ 0 ] yp [ 0 ] = xp [ 0 ] ^ yp [ 0 ] xp [ 0 ] = xp [ 0 ] ^ yp [ 0 ...
CodeGen-main
data/transcoder_evaluation_gfg/python/SWAP_TWO_NUMBERS_WITHOUT_USING_TEMPORARY_VARIABLE.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 sys def f_gold ( a , n ) : mn = sys.maxsize sum = 0 for i in range ( n ) : mn = min ( a [ i ] , mn )...
CodeGen-main
data/transcoder_evaluation_gfg/python/MINIMUM_COST_CONNECT_WEIGHTED_NODES_REPRESENTED_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 ( notes , n ) : fiveCount = 0 tenCount = 0 for i in range ( n ) : if ( notes [ i ] == 5 ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/CHECK_IF_X_CAN_GIVE_CHANGE_TO_EVERY_PERSON_IN_THE_QUEUE.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) dp = [[0 for x in range(N + 1)] for y in range(N + 1)] for l in range(1, N + 1): ...
CodeGen-main
data/transcoder_evaluation_gfg/python/MINIMUM_STEPS_TO_DELETE_A_STRING_AFTER_REPEATED_DELETION_OF_PALINDROME_SUBSTRINGS.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 ) : length = int ( s / 3 ) s -= length breadth = s / 2 height = s - breadth return int ( leng...
CodeGen-main
data/transcoder_evaluation_gfg/python/MAXIMIZE_VOLUME_CUBOID_GIVEN_SUM_SIDES_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 ( n ) : C = [ [ 0 for x in range ( n + 1 ) ] for y in range ( n + 1 ) ] ; for i in range ( n + 1 ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/MAXIMUM_BINOMIAL_COEFFICIENT_TERM_VALUE.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 ) + ( n * n * n ) #TOFILL if __name__ == '__main__': param = [ (90,), (95,)...
CodeGen-main
data/transcoder_evaluation_gfg/python/N_TH_TERM_SERIES_2_12_36_80_150.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 start = 1 end = x while ( start <= end ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/SQUARE_ROOT_OF_AN_INTEGER_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(n): prime = [0] * (n + 1) sum = 0 max = int(n / 2) for p in range(2, max + 1): if prime[p] ==...
CodeGen-main
data/transcoder_evaluation_gfg/python/SUM_LARGEST_PRIME_FACTOR_NUMBER_LESS_EQUAL_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 ( M , n , m ) : count = 0 for i in range ( n ) : for j in range ( m ) : if M [ i ] [ j ] ...
CodeGen-main
data/transcoder_evaluation_gfg/python/COUNT_NEGATIVE_NUMBERS_IN_A_COLUMN_WISE_ROW_WISE_SORTED_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 ) : for i in range ( int ( ( n - 2 ) / 2 ) + 1 ) : if arr [ 2 * i + 1 ] > arr [ i ] : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/HOW_TO_CHECK_IF_A_GIVEN_ARRAY_REPRESENTS_A_BINARY_HEAP_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 ) : first = 1 second = 1 number = 2 next = 1 while ( next ) : next = ( first + second...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIBONACCI_MODULO_P.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 ) : ans = 0 for i in range ( 1 , N + 1 ) : for j in range ( 1 , N + 1 ) : ans += i //...
CodeGen-main
data/transcoder_evaluation_gfg/python/SUM_MATRIX_ELEMENT_ELEMENT_INTEGER_DIVISION_ROW_COLUMN.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 ) : a.sort ( ) ; s = [ ] ; i = 0 ; j = n - 1 ; while ( i < j ) : s.append ( ( a [...
CodeGen-main
data/transcoder_evaluation_gfg/python/MINIMUM_DIFFERENCE_BETWEEN_GROUPS_OF_SIZE_TWO.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): max = 0 min = 0 arr.sort() j = n - 1 for i in range(m): min += arr[i] ...
CodeGen-main
data/transcoder_evaluation_gfg/python/DIFFERENCE_MAXIMUM_SUM_MINIMUM_SUM_N_M_ELEMENTSIN_REVIEW.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 ) : n = len ( s ) auxArr = [ 0 for i in range ( n ) ] if ( s [ 0 ] == '1' ) : auxArr [ 0 ] = ...
CodeGen-main
data/transcoder_evaluation_gfg/python/NUMBER_OF_SUBSTRINGS_WITH_ODD_DECIMAL_VALUE_IN_A_BINARY_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(arr, n): if (n <= 0): return 0 incl = arr[0] excl = 0 for i in range(1, n): incl_new ...
CodeGen-main
data/transcoder_evaluation_gfg/python/MINIMUM_TIME_TO_FINISH_TASKS_WITHOUT_SKIPPING_TWO_CONSECUTIVE.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 ) : N = 10 count = 1 for i in range ( 1 , n + 1 ) : count = int ( count * ( N + i - 1 ) ) ...
CodeGen-main
data/transcoder_evaluation_gfg/python/TOTAL_NUMBER_OF_NON_DECREASING_NUMBERS_WITH_N_DIGITS_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 ( n , k ) : if ( k <= 0 ) : return n return ( n & ~ ( 1 << ( k - 1 ) ) ) #TOFILL if __name__ == '_...
CodeGen-main
data/transcoder_evaluation_gfg/python/HOW_TO_TURN_OFF_A_PARTICULAR_BIT_IN_A_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 ) : return ( n * ( n - 1 ) * ( n - 2 ) // 6 ) #TOFILL if __name__ == '__main__': param = [ (67,), ...
CodeGen-main
data/transcoder_evaluation_gfg/python/NUMBER_OF_TRIANGLES_IN_A_PLANE_IF_NO_MORE_THAN_TWO_POINTS_ARE_COLLINEAR.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 ( ( n * ( 2 * n - 1 ) * ( 2 * n + 1 ) ) / 3 ) #TOFILL if __name__ == '__main__': param ...
CodeGen-main
data/transcoder_evaluation_gfg/python/SUM_SERIES_12_32_52_2N_12_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 ( string ) : string = string [ : : - 1 ] return string #TOFILL if __name__ == '__main__': param = [ ...
CodeGen-main
data/transcoder_evaluation_gfg/python/STACK_SET_3_REVERSE_STRING_USING_STACK.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 ( stack1 , stack2 , stack3 , n1 , n2 , n3 ) : sum1 , sum2 , sum3 = 0 , 0 , 0 for i in range ( n1 ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_MAXIMUM_SUM_POSSIBLE_EQUAL_SUM_THREE_STACKS.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 ) : return math.log2 ( n & - n ) + 1 #TOFILL if __name__ == '__main__': param = [ (45...
CodeGen-main
data/transcoder_evaluation_gfg/python/POSITION_OF_RIGHTMOST_SET_BIT.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 , m , n ) : for i in range ( n ) : for j in range ( m ) : A [ i ] [ j ] -= B [ i ] [ ...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_NUMBER_TRANSFORMATION_MAKE_TWO_MATRIX_EQUAL.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 ) : x1 = a [ 0 ] x2 = 1 for i in range ( 1 , n ) : x1 = x1 ^ a [ i ] for i in range (...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_THE_MISSING_NUMBER_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 ( a , b , c ) : if ( ( a < b and b < c ) or ( c < b and b < a ) ) : return b ; if ( ( b < a and a < c...
CodeGen-main
data/transcoder_evaluation_gfg/python/MIDDLE_OF_THREE_USING_MINIMUM_COMPARISONS.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 , 1 ) : if ( arr [...
CodeGen-main
data/transcoder_evaluation_gfg/python/CHECK_ARRAY_REPRESENTS_INORDER_BINARY_SEARCH_TREE_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 ) : return ( n % 2 == 0 ) #TOFILL if __name__ == '__main__': param = [ (67,), (90,), (55,)...
CodeGen-main
data/transcoder_evaluation_gfg/python/CHECK_WHETHER_GIVEN_NUMBER_EVEN_ODD.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 ) : mp = { } maxDict = 0 for i in range ( n ) : if arr [ i ] not in mp.keys ( ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/MAXIMUM_DISTANCE_TWO_OCCURRENCES_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 ( symb , oper , n ) : F = [ [ 0 for i in range ( n + 1 ) ] for i in range ( n + 1 ) ] T = [ [ 0 for i in rang...
CodeGen-main
data/transcoder_evaluation_gfg/python/DYNAMIC_PROGRAMMING_SET_37_BOOLEAN_PARENTHESIZATION_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 ( str , n ) : dp = [ [ 0 for x in range ( n ) ] for y in range ( n ) ] P = [ [ False for x in range ( n ) ] f...
CodeGen-main
data/transcoder_evaluation_gfg/python/COUNT_PALINDROME_SUB_STRINGS_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 ( arr , n ) : arr.sort ( ) count = 0 ; max_count = 0 ; min_count = n for i in range ( 0 , ( n - 1 ) ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/DIFFERENCE_BETWEEN_HIGHEST_AND_LEAST_FREQUENCIES_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 ( s ) : l = len ( s ) s1 = "" if ( l % 2 == 0 ) : isEven = True else : isEven = False...
CodeGen-main
data/transcoder_evaluation_gfg/python/DECODE_MEDIAN_STRING_ORIGINAL_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 ( arr , n , k ) : count = 0 for i in range ( 0 , n ) : for j in range ( i + 1 , n ) : if ...
CodeGen-main
data/transcoder_evaluation_gfg/python/COUNT_PAIRS_DIFFERENCE_EQUAL_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 ( arr , n ) : s = set ( ) sum = 0 for i in range ( n ) : sum += arr [ i ] if sum % 2 != 0 : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/CHECK_EXIST_TWO_ELEMENTS_ARRAY_WHOSE_SUM_EQUAL_SUM_REST_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 ) : num = n ; dec_value = 0 ; base = 1 ; temp = num ; while ( temp ) : last_digit = t...
CodeGen-main
data/transcoder_evaluation_gfg/python/PROGRAM_BINARY_DECIMAL_CONVERSION.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 ( price , n , k ) : profit = [ [ 0 for i in range ( n + 1 ) ] for j in range ( k + 1 ) ] for i in range ( 1 ,...
CodeGen-main
data/transcoder_evaluation_gfg/python/MAXIMUM_PROFIT_BY_BUYING_AND_SELLING_A_SHARE_AT_MOST_K_TIMES_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 , low , high , x ) : if ( low > high ) : return - 1 if ( x >= arr [ high ] ) : return h...
CodeGen-main
data/transcoder_evaluation_gfg/python/FLOOR_IN_A_SORTED_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 ( A , B , m , n ) : dp = [ [ 0 for i in range ( m + 1 ) ] for j in range ( n + 1 ) ] for i in range ( 1 , n +...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_MAXIMUM_DOT_PRODUCT_TWO_ARRAYS_INSERTION_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 ( a , n , k ) : max_so_far = - 2147483648 max_ending_here = 0 for i in range ( n * k ) : max_endi...
CodeGen-main
data/transcoder_evaluation_gfg/python/MAXIMUM_SUBARRAY_SUM_ARRAY_CREATED_REPEATED_CONCATENATION.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 ) : for i in range ( k , n ) : max_var = arr [ k - 1 ] pos = k - 1 for j in...
CodeGen-main
data/transcoder_evaluation_gfg/python/K_SMALLEST_ELEMENTS_ORDER_USING_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 ( n ) : i = 1 ; res = 0.0 ; sign = True ; while ( n > 0 ) : n = n - 1 ; if ( sign ) :...
CodeGen-main
data/transcoder_evaluation_gfg/python/SUM_SERIES_23_45_67_89_UPTO_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 ( arr , n ) : dp = [ 0 ] * n if ( n == 1 ) : return arr [ 0 ] if ( n == 2 ) : return min ...
CodeGen-main
data/transcoder_evaluation_gfg/python/MINIMUM_SUM_SUBSEQUENCE_LEAST_ONE_EVERY_FOUR_CONSECUTIVE_ELEMENTS_PICKED.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 True i = 1 for i in range ( 1 , n ) : if arr [ i - 1...
CodeGen-main
data/transcoder_evaluation_gfg/python/CHECK_REVERSING_SUB_ARRAY_MAKE_ARRAY_SORTED_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 ( x , y ) : return ( ( x ^ y ) < 0 ) ; #TOFILL if __name__ == '__main__': param = [ (59,-99,), (-2...
CodeGen-main
data/transcoder_evaluation_gfg/python/DETECT_IF_TWO_INTEGERS_HAVE_OPPOSITE_SIGNS.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 , k ) : c1 = ( b - a ) - 1 c2 = ( k - b ) + ( a - 1 ) if ( c1 == c2 ) : return 0 retu...
CodeGen-main
data/transcoder_evaluation_gfg/python/COUNT_OBTUSE_ANGLES_CIRCLE_K_EQUIDISTANT_POINTS_2_GIVEN_POINTS.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 , K ) : n = len ( A ) ; pre_sum = [ 0 ] * ( n + 1 ) ; pre_sum [ 0 ] = 0 ; for i in range ( n ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/MAXIMUM_AVERAGE_SUM_PARTITION_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 collections def f_gold ( arr , n ) : q = collections.deque ( [ ] ) arr.sort ( ) q.append ( arr [ 0 ] ) f...
CodeGen-main
data/transcoder_evaluation_gfg/python/NUMBER_VISIBLE_BOXES_PUTTING_ONE_INSIDE_ANOTHER.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 ; for i in range ( 1 , N + 1 ) : ans += ( i % K ) ; return ans ; #TOFILL i...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_SUM_MODULO_K_FIRST_N_NATURAL_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 ( string ) : length = len ( string ) if string [ 0 ] < 'A' or string [ 0 ] > 'Z' : return False i...
CodeGen-main
data/transcoder_evaluation_gfg/python/CHECK_GIVEN_SENTENCE_GIVEN_SET_SIMPLE_GRAMMER_RULES.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 ) : a = sorted ( a ) num1 , num2 = 0 , 0 for i in range ( n ) : if i % 2 == 0 : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/MINIMUM_SUM_TWO_NUMBERS_FORMED_DIGITS_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 ) : if ( n == 0 ) : return "0" ; bin = "" ; while ( n > 0 ) : if ( n & 1 == 0 ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/DECIMAL_BINARY_CONVERSION_WITHOUT_USING_ARITHMETIC_OPERATORS.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 ) : maxA = - 100000000 maxB = - 100000000 maxC = - 100000000 for i in range ( 0 , n ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/MAXIMUM_TRIPLET_SUM_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(st): for i in range(1, len(st)): if (st[i - 1] == 'A' and st[i] == 'B'): st[i - 1] = 'C' ...
CodeGen-main
data/transcoder_evaluation_gfg/python/REPLACE_OCCURRENCES_STRING_AB_C_WITHOUT_USING_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. # import math def f_gold ( x , y ) : x = x % 10 if y != 0 : y = y % 4 + 4 return ( ( ( int ) ( math.pow ( x ,...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_UNIT_DIGIT_X_RAISED_POWER_Y_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 ) : n = len ( S ) if ( n < 2 ) : return j = 0 for i in range ( n ) : if ( S [ j ]...
CodeGen-main
data/transcoder_evaluation_gfg/python/REMOVE_CONSECUTIVE_DUPLICATES_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 ( a , n ) : if ( n == 1 ) : return a [ 0 ] max_neg = float ( '-inf' ) min_pos = float ( 'inf' ) ...
CodeGen-main
data/transcoder_evaluation_gfg/python/MINIMUM_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 ( n ) : return n & ( n - 1 ) #TOFILL if __name__ == '__main__': param = [ (9,), (54,), (60,), ...
CodeGen-main
data/transcoder_evaluation_gfg/python/TURN_OFF_THE_RIGHTMOST_SET_BIT.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 ) : return ( ( ( 15 + ( 7 * ( math.sqrt ( 5 ) ) ) ) / 4 ) * ( math.pow ( side , 3 ) ) ) #TO...
CodeGen-main
data/transcoder_evaluation_gfg/python/CALCULATE_VOLUME_DODECAHEDRON.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 , l , h ) : if l >= h : return if arr [ l ] > arr [ h ] : t = arr [ l ] arr [ l...
CodeGen-main
data/transcoder_evaluation_gfg/python/STOOGE_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 ( XY , n , Xmin , Ymin , Xmax , Ymax ) : print ( "Point inside the viewing pane:" ) for i in range ( n ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/POINT_CLIPPING_ALGORITHM_COMPUTER_GRAPHICS.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 , arr_size , sum ) : A.sort ( ) for i in range ( 0 , arr_size - 2 ) : l = i + 1 r = arr_s...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_A_TRIPLET_THAT_SUM_TO_A_GIVEN_VALUE_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 ( x1 , y1 , x2 , y2 ) : return ( x1 * ( y2 - y1 ) == y1 * ( x2 - x1 ) ) #TOFILL if __name__ == '__main__': ...
CodeGen-main
data/transcoder_evaluation_gfg/python/CHECK_LINE_PASSES_ORIGIN.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): hash = dict() maximum = 0 for i in arr: if (i < 0): if abs(i) not in hash.ke...
CodeGen-main
data/transcoder_evaluation_gfg/python/INTEGER_POSITIVE_VALUE_POSITIVE_NEGATIVE_VALUE_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 ( x , y , z ) : c = 0 while ( x and y and z ) : x = x - 1 y = y - 1 z = z - 1 ...
CodeGen-main
data/transcoder_evaluation_gfg/python/SMALLEST_OF_THREE_INTEGERS_WITHOUT_COMPARISON_OPERATORS.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 , m ) : return n if ( n == m ) else 1 #TOFILL if __name__ == '__main__': param = [ (57,57,), (...
CodeGen-main
data/transcoder_evaluation_gfg/python/GCD_ELEMENTS_GIVEN_RANGE.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 , x , y ) : if a == 0 : x = 0 y = 1 return b x1 = 1 y1 = 1 gcd = f_go...
CodeGen-main
data/transcoder_evaluation_gfg/python/BASIC_AND_EXTENDED_EUCLIDEAN_ALGORITHMS_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 ( str ) : i = 0 ; j = len ( str ) - 1 ; while ( i < j ) : if ( str [ i ] != str [ j ] ) : ...
CodeGen-main
data/transcoder_evaluation_gfg/python/PERFECT_REVERSIBLE_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(n): sum = 0 while (n != 0): sum = sum + int(n % 10) n = int(n / 10) return sum #TOFILL ...
CodeGen-main
data/transcoder_evaluation_gfg/python/HOW_CAN_WE_SUM_THE_DIGITS_OF_A_GIVEN_NUMBER_IN_SINGLE_STATEMENT.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 ) : sum = 0 for i in range ( n ) : sum += i * ( n - i ) return 2 * sum #TOFILL if __name__...
CodeGen-main
data/transcoder_evaluation_gfg/python/SUM_MATRIX_ELEMENT_ABSOLUTE_DIFFERENCE_ROW_COLUMN_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 ( n ) : DP = [ 0 ] * ( n + 1 ) DP [ 0 ] = 0 DP [ 1 ] = 1 for i in range ( 2 , n + 1 ) : if ( ...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_N_TH_ELEMENT_FROM_STERNS_DIATOMIC_SERIES.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 sys def f_gold ( arr , n ) : res = - sys.maxsize - 1 for i in range ( n ) : prefix_sum = arr [ i ] ...
CodeGen-main
data/transcoder_evaluation_gfg/python/MAXIMUM_EQULIBRIUM_SUM_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 ) : sum = 0 for i in range ( 1 , n + 1 ) : sum += int ( n / i ) * i return int ( sum ) #TOF...
CodeGen-main
data/transcoder_evaluation_gfg/python/SUM_DIVISORS_1_N_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 , n ) : cnt = dict ( ) ans = 0 pre_sum = 0 for i in range ( n ) : ans += ( i * a [ i ] ) ...
CodeGen-main
data/transcoder_evaluation_gfg/python/SUM_FAI_AJ_PAIRS_ARRAY_N_INTEGERS.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 ( string ) : l = 0 h = len ( string ) - 1 while h > l : l += 1 h -= 1 if string [...
CodeGen-main
data/transcoder_evaluation_gfg/python/CHECK_GIVEN_STRING_ROTATION_PALINDROME.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 , n , arr2 , m ) : table = [ 0 ] * m for j in range ( m ) : table [ j ] = 0 for i in range...
CodeGen-main
data/transcoder_evaluation_gfg/python/LONGEST_COMMON_INCREASING_SUBSEQUENCE_LCS_LIS.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 ) : fw = [ 0 for k in range ( n ) ] bw = [ 0 for k in range ( n ) ] cur_max , max_so_far = arr ...
CodeGen-main
data/transcoder_evaluation_gfg/python/MAXIMUM_SUM_SUBARRAY_REMOVING_ONE_ELEMENT.py