dataset_name
stringclasses
1 value
src_lang
stringclasses
1 value
entry_func
stringclasses
1 value
prefix
stringlengths
65
1.25k
import_str
listlengths
0
1
suffix
null
demos
listlengths
0
0
data_id
stringlengths
9
106
doc_string
stringclasses
1 value
tgt_lang
stringclasses
1 value
compare_func
listlengths
0
0
solution
stringlengths
40
1.94k
task_name
stringclasses
1 value
test_cases
listlengths
10
11
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int a [ ], int n ) { sort ( a, a + n ); int num1 = 0; int num2 = 0; for ( int i = 0; i < n; i ++ ) { if ( i % 2 == 0 ) num1 = num1 * 10 + a [ i ]; else num2 = num2 * 10 + a [ i ]; } return num2 + num1; }
[]
null
[]
CHECK_STRING_FOLLOWS_ANBN_PATTERN_NOT
python
[]
def f_gold ( str ) : n = len ( str ) for i in range ( n ) : if ( str [ i ] != 'a' ) : break if ( i * 2 != n ) : return False for j in range ( i , n ) : if ( str [ j ] != 'b' ) : return False return True
code_translation
[ [ "'ba'", "False" ], [ "'aabb'", "True" ], [ "'abab'", "False" ], [ "'aaabb'", "False" ], [ "'aabbb'", "False" ], [ "'abaabbaa'", "False" ], [ "'abaababb'", "False" ], [ "'bbaa'", "False" ], [ "'11001000'", "Fals...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int x, unsigned int y, int p ) { int res = 1; x = x % p; while ( y > 0 ) { if ( y & 1 ) res = ( res * x ) % p; y = y >> 1; x = ( x * x ) % p; } return res; }
[ "import math" ]
null
[]
MAXIMUM_SUBARRAY_SUM_USING_PREFIX_SUM
python
[]
import math def f_gold ( arr , n ) : min_prefix_sum = 0 res = - math.inf prefix_sum = [ ] prefix_sum.append ( arr [ 0 ] ) for i in range ( 1 , n ) : prefix_sum.append ( prefix_sum [ i - 1 ] + arr [ i ] ) for i in range ( n ) : res = max ( res , prefix_sum [ i ] - min_prefix_sum ) min_prefix_sum = min ( min_prefix_sum , prefix_sum [ i ] ) return res
code_translation
[ [ "[8, 9, 11, 17, 18, 19, 23, 24, 27, 30, 31, 31, 35, 44, 46, 47, 49, 51, 55, 58, 59, 61, 65, 67, 71, 71, 71, 71, 78, 78, 82, 91, 98], 20", "633" ], [ "[-82, -28, -66, -52, -36, 36, -88, 52, -62, 46, 42, 26, -60, 18, -52, 38, 94, -68, 44, -94, 14, 36, -70], 15", "114" ], [ "[0, 0, 0, 0, ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; bool f_gold ( unsigned int n ) { bool parity = 0; while ( n ) { parity = ! parity; n = n & ( n - 1 ); } return parity; }
[]
null
[]
COUNT_INDEX_PAIRS_EQUAL_ELEMENTS_ARRAY_1
python
[]
def f_gold ( arr , n ) : mp = dict ( ) for i in range ( n ) : if arr [ i ] in mp.keys ( ) : mp [ arr [ i ] ] += 1 else : mp [ arr [ i ] ] = 1 ans = 0 for it in mp : count = mp [ it ] ans += ( count * ( count - 1 ) ) // 2 return ans
code_translation
[ [ "[5, 11, 18, 22, 40, 46, 50, 51, 53, 55, 64, 67, 73, 78, 86], 14", "0" ], [ "[14, -98, 98, 58, -82, 90, -80, -56, -30, -36, -56, -30, -58, 68, 72, -76, 38, -90, -72, 4, -32, 32, -28, 2, 12, -72, 54, 2, 0, -74, 8, 12, 46, 72, -84, -66, 70, 18, 26, 72, -26, 44, -8, 20, -32, -56, 28], 24", "2" ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( string str ) { int n = str . length ( ); int oddDigSum = 0, evenDigSum = 0; for ( int i = 0; i < n; i ++ ) { if ( i % 2 == 0 ) oddDigSum += ( str [ i ] - '0' ); else evenDigSum += ( str [ i ] - '0' ); } return ( ( oddDigSum - evenDigSum ) % 11 == 0 ); }
[]
null
[]
LARGEST_SUBARRAY_WITH_EQUAL_NUMBER_OF_0S_AND_1S
python
[]
def f_gold(arr, n): sum = 0 maxsize = - 1 for i in range(0, n - 1): sum = - 1 if (arr[i] == 0) else 1 for j in range(i + 1, n): sum = sum + (- 1) if (arr[j] == 0) else sum + 1 if (sum == 0 and maxsize < j - i + 1): maxsize = j - i + 1 startindex = i if (maxsize == - 1): print("No such subarray") else: print(startindex, "to", startindex + maxsize - 1) return maxsize
code_translation
[ [ "[56, 8, 67, 35, 19, 82, 81, 66, 10, 24, 82, 2, 42, 48, 18, 63, 48, 74, 60, 64, 64, 95, 95, 20, 95, 55, 63, 96, 54], 26", "-1" ], [ "[78, 67, 1, 78, 48, 83, 17, 19, 21, 44, 99, 68, 16, 54, 9], 8", "-1" ], [ "[3, 69, 97, 21, 12, 67, 45, 53, 77, 70, 26, 43], 9", "-1" ], [ "[2...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; unsigned int f_gold ( unsigned int n ) { unsigned int p = 1; if ( n && ! ( n & ( n - 1 ) ) ) return n; while ( p < n ) p <<= 1; return p; }
[]
null
[]
COUNT_PAIRS_DIFFERENCE_EQUAL_K_1
python
[]
def f_gold ( arr , n , k ) : count = 0 arr.sort ( ) l = 0 r = 0 while r < n : if arr [ r ] - arr [ l ] == k : count += 1 l += 1 r += 1 elif arr [ r ] - arr [ l ] > k : l += 1 else : r += 1 return count
code_translation
[ [ "[5, 5, 10, 19, 29, 32, 40, 60, 65, 70, 72, 89, 92], 7, 12", "0" ], [ "[-98, -90, -88, -82, -80, -78, -74, -74, -72, -62, -58, -58, -56, -52, -48, -46, -38, -38, -30, -12, -10, 4, 8, 8, 14, 22, 24, 26, 36, 40, 40, 48, 56, 58, 58, 58, 60, 62, 64, 68, 68, 74, 84], 24, 36", "7" ], [ "[0, ...
transcoder-geeksforgeeks
cpp
f_gold
null
[]
null
[]
COUNT_SORTED_ROWS_MATRIX
python
[]
def f_gold ( mat , r , c ) : result = 0 for i in range ( r ) : j = 0 for j in range ( c - 1 ) : if mat [ i ] [ j + 1 ] <= mat [ i ] [ j ] : break if j == c - 2 : result += 1 for i in range ( 0 , r ) : j = 0 for j in range ( c - 1 , 0 , - 1 ) : if mat [ i ] [ j - 1 ] <= mat [ i ] [ j ] : break if c > 1 and j == 1 : result += 1 return result
code_translation
[ [ "[[4, 12, 13, 24, 25, 26, 27, 35, 41, 60, 69, 71, 73, 78, 85, 86, 95, 99], [1, 13, 18, 25, 41, 42, 44, 45, 49, 49, 51, 52, 59, 63, 64, 67, 78, 97], [1, 2, 11, 18, 23, 26, 30, 31, 41, 42, 45, 71, 75, 90, 91, 92, 95, 97], [26, 30, 44, 46, 46, 54, 56, 60, 67, 68, 75, 77, 77, 83, 87, 87, 94, 98], [19, 20, 27, 31,...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int ar [ ], int ar_size ) { int res = 0; for ( int i = 0; i < ar_size; i ++ ) res = res ^ ar [ i ]; return res; }
[]
null
[]
COUNT_SUBSTRINGS_WITH_SAME_FIRST_AND_LAST_CHARACTERS
python
[]
def f_gold ( s ) : result = 0 ; n = len ( s ) ; for i in range ( n ) : for j in range ( i , n ) : if ( s [ i ] == s [ j ] ) : result = result + 1 return result
code_translation
[ [ "'LZIKA'", "5" ], [ "'0556979952'", "16" ], [ "'110010'", "12" ], [ "'kGaYfd'", "6" ], [ "'413567670657'", "19" ], [ "'01001'", "9" ], [ "'EQPuFa'", "6" ], [ "'48848378'", "15" ], [ "'110'", "4" ], [ "'...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int n ) { int arr [ n ] [ n ]; for ( int i = 0; i < n; i ++ ) for ( int j = 0; j < n; j ++ ) arr [ i ] [ j ] = abs ( i - j ); int sum = 0; for ( int i = 0; i < n; i ++ ) for ( int j = 0; j < n; j ++ ) sum += arr [ i ] [ j ]; return sum; }
[]
null
[]
DIFFERENCE_BETWEEN_HIGHEST_AND_LEAST_FREQUENCIES_IN_AN_ARRAY
python
[]
def f_gold ( arr , n ) : arr.sort ( ) count = 0 ; max_count = 0 ; min_count = n for i in range ( 0 , ( n - 1 ) ) : if arr [ i ] == arr [ i + 1 ] : count += 1 continue else : max_count = max ( max_count , count ) min_count = min ( min_count , count ) count = 0 return max_count - min_count
code_translation
[ [ "[5, 15, 19, 22, 28, 29, 39, 46, 46, 49, 51, 55, 62, 69, 72, 72, 72, 74, 79, 92, 92, 93, 95, 96], 15", "1" ], [ "[-92, -92, -78, -74, -70, -66, -60, -54, -50, -48, -34, -32, -26, -24, -22, -14, -10, -10, -6, 2, 4, 6, 12, 18, 34, 42, 52, 56, 76, 92, 92], 30", "1" ], [ "[0, 0, 0, 0, 0, 0...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( int a, int b ) { if ( b == 0 ) return 1; int answer = a; int increment = a; int i, j; for ( i = 1; i < b; i ++ ) { for ( j = 1; j < a; j ++ ) { answer += increment; } increment = answer; } return answer; }
[]
null
[]
CHECK_WHETHER_NUMBER_DUCK_NUMBER_NOT
python
[]
def f_gold ( num ) : l = len ( num ) count_zero = 0 i = 1 while i < l : ch = num [ i ] if ( ch == "0" ) : count_zero = count_zero + 1 i = i + 1 return count_zero
code_translation
[ [ "'HLlQWSphZcIC'", "0" ], [ "'080287724'", "1" ], [ "'0000100000'", "8" ], [ "' Q'", "0" ], [ "'4247040983'", "2" ], [ "'00001011101'", "5" ], [ "'LbNsnYTHmLbCf'", "0" ], [ "'24'", "0" ], [ "'110'", "1" ], [...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; bool f_gold ( int arr1 [ ], int arr2 [ ], int m, int n ) { int i = 0, j = 0; if ( m < n ) return 0; sort ( arr1, arr1 + m ); sort ( arr2, arr2 + n ); while ( i < n && j < m ) { if ( arr1 [ j ] < arr2 [ i ] ) j ++; else if ( arr1 [ j ] == arr2 [ i ] ) { j ++; i ++; } else if ( arr1 [ j ] > arr2 [ i ] ) return 0; } return ( i < n ) ? false : true; }
[]
null
[]
AREA_SQUARE_CIRCUMSCRIBED_CIRCLE
python
[]
def f_gold ( r ) : return ( 2 * r * r )
code_translation
[ [ "14", "392" ], [ "78", "12168" ], [ "45", "4050" ], [ "66", "8712" ], [ "18", "648" ], [ "32", "2048" ], [ "60", "7200" ], [ "16", "512" ], [ "99", "19602" ], [ "65", "8450" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; void f_gold ( int arr [ ], int n ) { vector < int > evenArr; vector < int > oddArr; for ( int i = 0; i < n; i ++ ) { if ( ! ( i % 2 ) ) evenArr . push_back ( arr [ i ] ); else oddArr . push_back ( arr [ i ] ); } sort ( evenArr . begin ( ), evenArr . end ( ) ); sort ( oddArr . begin ( ), oddArr . end ( ), greater < int > ( ) ); int i = 0; for ( int j = 0; j < evenArr . size ( ); j ++ ) arr [ i ++ ] = evenArr [ j ]; for ( int j = 0; j < oddArr . size ( ); j ++ ) arr [ i ++ ] = oddArr [ j ]; }
[]
null
[]
NUMBER_NON_NEGATIVE_INTEGRAL_SOLUTIONS_B_C_N
python
[]
def f_gold ( n ) : result = 0 for i in range ( n + 1 ) : for j in range ( n + 1 ) : for k in range ( n + 1 ) : if i + j + k == n : result += 1 return result
code_translation
[ [ "62", "2016" ], [ "44", "1035" ], [ "37", "741" ], [ "81", "3403" ], [ "14", "120" ], [ "20", "231" ], [ "76", "3003" ], [ "72", "2701" ], [ "96", "4753" ], [ "52", "1431" ] ]
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; bool f_gold ( int x, int y ) { int res1 = log ( y ) / log ( x ); double res2 = log ( y ) / log ( x ); return ( res1 == res2 ); }
[]
null
[]
CHECK_TWO_GIVEN_CIRCLES_TOUCH_INTERSECT
python
[]
def f_gold(x1, y1, x2, y2, r1, r2): distSq = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) radSumSq = (r1 + r2) * (r1 + r2) if (distSq == radSumSq): return 1 elif (distSq > radSumSq): return - 1 else: return 0
code_translation
[ [ "11, 36, 62, 64, 50, 4", "-1" ], [ "87, 1, 62, 64, 54, 41", "0" ], [ "51, 1, 47, 90, 14, 71", "-1" ], [ "89, 67, 9, 52, 94, 21", "0" ], [ "64, 10, 79, 45, 67, 78", "0" ], [ "57, 86, 99, 43, 83, 63", "0" ], [ "65, 90, 42, 82, 77, 32", ...
transcoder-geeksforgeeks
cpp
f_gold
using namespace std; int f_gold ( char arr [ ], int n, int k ) { int res = 0; vector < int > thi; vector < int > pol; for ( int i = 0; i < n; i ++ ) { if ( arr [ i ] == 'P' ) pol . push_back ( i ); else if ( arr [ i ] == 'T' ) thi . push_back ( i ); } int l = 0, r = 0; while ( l < thi . size ( ) && r < pol . size ( ) ) { if ( abs ( thi [ l ] - pol [ r ] ) <= k ) { res ++; l ++; r ++; } else if ( thi [ l ] < pol [ r ] ) l ++; else r ++; } return res; }
[]
null
[]
MINIMUM_NUMBER_PLATFORMS_REQUIRED_RAILWAYBUS_STATION
python
[]
def f_gold ( arr , dep , n ) : arr.sort ( ) dep.sort ( ) plat_needed = 1 result = 1 i = 1 j = 0 while ( i < n and j < n ) : if ( arr [ i ] < dep [ j ] ) : plat_needed += 1 i += 1 if ( plat_needed > result ) : result = plat_needed else : plat_needed -= 1 j += 1 return result
code_translation
[ [ "[8, 24, 28, 64, 75, 86, 93, 95], [19, 30, 41, 51, 62, 68, 85, 96], 6", "2" ], [ "[-94, -92, -86, -78, -68, -58, -54, -42, -30, -30, -28, -26, -18, -8, -6, -4, 0, 0, 2, 6, 8, 14, 16, 30, 34, 50, 58, 58, 66, 78, 84, 86, 94, 98], [-98, -90, -84, -76, -64, -62, -52, -48, -44, -34, -24, -22, -12, -10,...