"{\"inputs\":\"\\\"Count distinct pairs with given sum | Java program to implement the above approach ; Function to count distinct pairs in array whose sum equal to K ; Stores count of distinct pairs whose sum equal to K ; Store frequency of each distinct element of the array ; Update frequency of arr [ i ] ; Traverse the map ; Stores key value of the map ; If i is the half of K ; If frequency of i greater than 1 ; Update cntPairs ; Update cntPairs ; Driver Code\\\"\\nSolution in Java:\",\"targets\":\"import java . util . * ; class GFG { static int cntDisPairs ( int arr [ ] , int N , int K ) { int cntPairs = 0 ; HashMap < Integer , Integer > cntFre = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( cntFre . containsKey ( arr [ i ] ) ) cntFre . put ( arr [ i ] , cntFre . get ( arr [ i ] ) + 1 ) ; else cntFre . put ( arr [ i ] , 1 ) ; } for ( Map . Entry < Integer , Integer > it : cntFre . entrySet ( ) ) { int i = it . getKey ( ) ; if ( 2 * i == K ) { if ( cntFre . get ( i ) > 1 ) cntPairs += 2 ; } else { if ( cntFre . containsKey ( K - i ) ) { cntPairs += 1 ; } } } cntPairs = cntPairs \\/ 2 ; return cntPairs ; } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 6 , 5 , 7 , 7 , 8 } ; int N = arr . length ; int K = 13 ; System . out . print ( cntDisPairs ( arr , N , K ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Minimum number of bracket reversals needed to make an expression balanced | Set | Returns count of minimum reversals for making expr balanced . Returns - 1 if expr cannot be balanced . ; length of expression must be even to make it balanced by using reversals . ; To store number of reversals required . ; To store number of unbalanced opening brackets . ; To store number of unbalanced closing brackets . ; If current bracket is open then increment open count . ; If current bracket is close , check if it balances opening bracket . If yes then decrement count of unbalanced opening bracket else increment count of closing bracket . ; For the case : \\\" } { \\\" or when one closing and one opening bracket remains for pairing , then both need to be reversed . ; Driver Code\\\"\\nSolution in Javascript:\",\"targets\":\"function countMinReversals ( expr ) { var len = expr . length ; if ( len % 2 ) return - 1 ; var ans = 0 ; var i ; var open = 0 ; var close = 0 ; for ( i = 0 ; i < len ; i ++ ) { if ( expr [ i ] == ' ' ) open ++ ; else { if ( ! open ) close ++ ; else open -- ; } } ans = ( close \\/ 2 ) + ( open \\/ 2 ) ; close %= 2 ; open %= 2 ; if ( close ) ans += 2 ; return ans ; } var expr = \\\" \\\" ; document . write ( countMinReversals ( expr ) ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Smallest power of 2 greater than or equal to n | Program to find smallest power of 2 greater than or equal to n ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function nextPowerOf2 ( $ n ) { $ count = 0 ; if ( $ n && ! ( $ n & ( $ n - 1 ) ) ) return $ n ; while ( $ n != 0 ) { $ n >>= 1 ; $ count += 1 ; } return 1 << $ count ; } $ n = 5 ; echo ( nextPowerOf2 ( $ n ) ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Maximum games played by winner | Method returns maximum games a winner needs to play in N - player tournament ; for 0 games , 1 player is needed for 1 game , 2 players are required ; loop until i - th Fibonacci number is less than or equal to N ; result is ( i - 2 ) because i will be incremented one extra in while loop and we want the last value which is smaller than N , so one more decrement ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function maxGameByWinner ( $ N ) { $ dp [ $ N ] = 0 ; $ dp [ 0 ] = 1 ; $ dp [ 1 ] = 2 ; $ i = 2 ; do { $ dp [ $ i ] = $ dp [ $ i - 1 ] + $ dp [ $ i - 2 ] ; } while ( $ dp [ $ i ++ ] <= $ N ) ; return ( $ i - 2 ) ; } $ N = 10 ; echo maxGameByWinner ( $ N ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"Count ways to reach the nth stair using step 1 , 2 or 3 | Program to find n - th stair using step size 1 or 2 or 3. ; Returns count of ways to reach n - th stair using 1 or 2 or 3 steps . ; Driver code\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint findStep ( int n ) { if ( n == 1 n == 0 ) return 1 ; else if ( n == 2 ) return 2 ; else return findStep ( n - 3 ) + findStep ( n - 2 ) + findStep ( n - 1 ) ; } int main ( ) { int n = 4 ; printf ( \\\" % d \\n \\\" , findStep ( n ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Longest Common Increasing Subsequence ( LCS + LIS ) | Returns the length and the LCIS of two arrays arr1 [ 0. . n - 1 ] and arr2 [ 0. . m - 1 ] ; table [ j ] is going to store length of LCIS ending with arr2 [ j ] . We initialize it as 0 , ; Traverse all elements of arr1 [ ] ; Initialize current length of LCIS ; For each element of arr1 [ ] , trvarse all elements of arr2 [ ] . ; If both the array have same elements . Note that we don 't break the loop here. ; Now seek for previous smaller common element for current element of arr1 ; The maximum value in table [ ] is out result ; Driver Code\\\"\\nSolution in Javascript:\",\"targets\":\"function LCIS ( arr1 , n , arr2 , m ) { let table = [ ] ; for ( let j = 0 ; j < m ; j ++ ) table [ j ] = 0 ; for ( let i = 0 ; i < n ; i ++ ) { let current = 0 ; for ( let j = 0 ; j < m ; j ++ ) { if ( arr1 [ i ] == arr2 [ j ] ) if ( current + 1 > table [ j ] ) table [ j ] = current + 1 ; if ( arr1 [ i ] > arr2 [ j ] ) if ( table [ j ] > current ) current = table [ j ] ; } } let result = 0 ; for ( let i = 0 ; i < m ; i ++ ) if ( table [ i ] > result ) result = table [ i ] ; return result ; } let arr1 = [ 3 , 4 , 9 , 1 ] ; let arr2 = [ 5 , 3 , 8 , 9 , 10 , 2 , 1 ] ; let n = arr1 . length ; let m = arr2 . length ; document . write ( \\\" \\\" + LCIS ( arr1 , n , arr2 , m ) ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Distinct state codes that appear in a string as contiguous sub | C ++ implementation of the approach ; Function to return the count of distinct state codes ; Insert every sub - string of length 2 in the set ; Return the size of the set ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int countDistinctCode ( string str ) { set < string > codes ; for ( int i = 0 ; i < str . length ( ) - 1 ; i ++ ) codes . insert ( str . substr ( i , 2 ) ) ; return codes . size ( ) ; } int main ( ) { string str = \\\" UPUP \\\" ; cout << countDistinctCode ( str ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Maximum sum in circular array such that no two elements are adjacent | Function to calculate the sum from 0 th position to ( n - 2 ) th position ; copy the element of original array to dp [ ] ; find the maximum element in the array ; start from 2 nd to n - 1 th pos ; traverse for all pairs bottom - up approach ; dp - condition ; find maximum sum ; return the maximum ; Function to find the maximum sum from 1 st position to n - 1 - th position ; Traverse from third to n - th pos ; bootom - up approach ; dp condition ; find max sum ; return max ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function maxSum1 ( $ arr , $ n ) { $ dp [ $ n ] = array ( ) ; $ maxi = 0 ; for ( $ i = 0 ; $ i < $ n - 1 ; $ i ++ ) { $ dp [ $ i ] = $ arr [ $ i ] ; if ( $ maxi < $ arr [ $ i ] ) $ maxi = $ arr [ $ i ] ; } for ( $ i = 2 ; $ i < $ n - 1 ; $ i ++ ) { for ( $ j = 0 ; $ j < $ i - 1 ; $ j ++ ) { if ( $ dp [ $ i ] < $ dp [ $ j ] + $ arr [ $ i ] ) { $ dp [ $ i ] = $ dp [ $ j ] + $ arr [ $ i ] ; if ( $ maxi < $ dp [ $ i ] ) $ maxi = $ dp [ $ i ] ; } } } return $ maxi ; } function maxSum2 ( $ arr , $ n ) { $ dp [ $ n ] = array ( ) ; $ maxi = 0 ; for ( $ i = 1 ; $ i < $ n ; $ i ++ ) { $ dp [ $ i ] = $ arr [ $ i ] ; if ( $ maxi < $ arr [ $ i ] ) $ maxi = $ arr [ $ i ] ; } for ( $ i = 3 ; $ i < $ n ; $ i ++ ) { for ( $ j = 1 ; $ j < $ i - 1 ; $ j ++ ) { if ( $ dp [ $ i ] < $ arr [ $ i ] + $ dp [ $ j ] ) { $ dp [ $ i ] = $ arr [ $ i ] + $ dp [ $ j ] ; if ( $ maxi < $ dp [ $ i ] ) $ maxi = $ dp [ $ i ] ; } } } return $ maxi ; } function findMaxSum ( $ arr , $ n ) { return max ( maxSum1 ( $ arr , $ n ) , maxSum2 ( $ arr , $ n ) ) ; } $ arr = array ( 1 , 2 , 3 , 1 ) ; $ n = sizeof ( $ arr ) ; echo findMaxSum ( $ arr , $ n ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"All possible values of floor ( N \\/ K ) for all values of K | Function to print all possible values of floor ( N \\/ K ) ; loop from 1 to N + 1 ; Driver code\\\"\\nSolution in Javascript:\",\"targets\":\"function allQuotients ( N ) { var s = new Set ( ) ; for ( var k = 1 ; k <= N + 1 ; k ++ ) { s . add ( parseInt ( N \\/ k ) ) ; } var ls = Array . from ( s ) . reverse ( ) ; ls . forEach ( v => document . write ( v + \\\" \\\" ) ) } var N = 5 ; allQuotients ( N ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Cutting a Rod | DP | C program for above approach ; Global Array for the purpose of memoization . ; A recursive program , using , memoization , to implement the rod cutting problem ( Top - Down ) . ; The maximum price will be zero , when either the length of the rod is zero or price is zero . ; If the length of the rod is less than the maximum length , Max_lene will consider it . Now depending upon the profit , either Max_lene we will take it or discard it . ; If the length of the rod is greater than the permitted size , Max_len we will not consider it . ; Max_lene Max_lenill return the maximum value obtained , Max_lenhich is present at the nth roMax_len and Max_lenth column . ; Driver program to test above functions ; Function Call\\\"\\nSolution in C:\",\"targets\":\"#include \\n#include \\nint max ( int a , int b ) { return ( a > b ) ? a : b ; } int t [ 9 ] [ 9 ] ; int un_kp ( int price [ ] , int length [ ] , int Max_len , int n ) { if ( n == 0 Max_len == 0 ) { return 0 ; } if ( length [ n - 1 ] <= Max_len ) { t [ n ] [ Max_len ] = max ( price [ n - 1 ] + un_kp ( price , length , Max_len - length [ n - 1 ] , n ) , un_kp ( price , length , Max_len , n - 1 ) ) ; } else { t [ n ] [ Max_len ] = un_kp ( price , length , Max_len , n - 1 ) ; } return t [ n ] [ Max_len ] ; } int main ( ) { int price [ ] = { 1 , 5 , 8 , 9 , 10 , 17 , 17 , 20 } ; int n = sizeof ( price ) \\/ sizeof ( price [ 0 ] ) ; int length [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { length [ i ] = i + 1 ; } int Max_len = n ; printf ( \\\" Maximum ▁ obtained ▁ value ▁ is ▁ % d ▁ \\n \\\" , un_kp ( price , length , n , Max_len ) ) ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Minimum increment operations to make the array in increasing order | Java program to find minimum moves required to make the array in increasing order ; function to find minimum moves required to make the array in increasing order ; to store answer ; iterate over an array ; non - increasing order ; add moves to answer ; increase the element ; return required answer ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static int MinimumMoves ( int a [ ] , int n , int x ) { int ans = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( a [ i ] <= a [ i - 1 ] ) { int p = ( a [ i - 1 ] - a [ i ] ) \\/ x + 1 ; ans += p ; a [ i ] += p * x ; } } return ans ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 3 , 3 , 2 } ; int x = 2 ; int n = arr . length ; System . out . println ( MinimumMoves ( arr , n , x ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Find a number that divides maximum array elements | JavaScript program to find a number that divides maximum array elements ; stores smallest prime factor for every number ; Calculating SPF ( Smallest Prime Factor ) for every number till MAXN . Time Complexity : O ( nloglogn ) ; marking smallest prime factor for every number to be itself . ; separately marking spf for every even number as 2 ; checking if i is prime ; marking SPF for all numbers divisible by i ; marking spf [ j ] if it is not previously marked ; A O ( log n ) function returning primefactorization by dividing by smallest prime factor at every step ; Function to find a number that divides maximum array elements ; precalculating Smallest Prime Factor ; Hash to store frequency of each divisors ; Traverse the array and get spf of each element ; calling getFactorization function ; Returns Set view ; Driver program\\\"\\nSolution in Javascript:\",\"targets\":\"let MAXN = 100001 ; let spf = new Array ( MAXN ) ; for ( let i = 0 ; i < MAXN ; i ++ ) { spf [ i ] = 0 ; } function sieve ( ) { spf [ 1 ] = 1 ; for ( let i = 2 ; i < MAXN ; i ++ ) spf [ i ] = i ; for ( let i = 4 ; i < MAXN ; i += 2 ) spf [ i ] = 2 ; for ( let i = 3 ; i * i < MAXN ; i ++ ) { if ( spf [ i ] == i ) { for ( let j = i * i ; j < MAXN ; j += i ) if ( spf [ j ] == j ) spf [ j ] = i ; } } } function getFactorization ( x ) { let ret = [ ] ; while ( x != 1 ) { let temp = spf [ x ] ; ret . push ( temp ) ; while ( x % temp == 0 ) x = Math . floor ( x \\/ temp ) ; } return ret ; } function maxElement ( A , n ) { sieve ( ) ; let m = new Map ( ) ; for ( let j = 0 ; j < n ; ++ j ) { let p = getFactorization ( A [ j ] ) ; for ( let i = 0 ; i < p . length ; i ++ ) m . set ( p [ i ] , m . get ( p [ i ] ) == null ? 0 : m . get ( p [ i ] ) + 1 ) ; } let cnt = 0 , ans = 10000000 ; for ( let [ key , value ] of m . entries ( ) ) { if ( value >= cnt ) { cnt = value ; if ( ans > key ) ans = key ; else ans = ans ; } } return ans ; } let A = [ 2 , 5 , 10 ] ; let n = A . length ; document . write ( maxElement ( A , n ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Cost to Balance the parentheses | CPP code to calculate the minimum cost to make the given parentheses balanced ; To store absolute count of balanced and unbalanced parenthesis ; o ( open bracket ) stores count of ' ( ' and c ( close bracket ) stores count of ' ) ' ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int costToBalance ( string s ) { if ( s . length ( ) == 0 ) cout << 0 << endl ; int ans = 0 ; int o = 0 , c = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s [ i ] == ' ( ' ) o ++ ; if ( s [ i ] == ' ) ' ) c ++ ; } if ( o != c ) return -1 ; int a [ s . size ( ) ] ; if ( s [ 0 ] == ' ( ' ) a [ 0 ] = 1 ; else a [ 0 ] = -1 ; if ( a [ 0 ] < 0 ) ans += abs ( a [ 0 ] ) ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( s [ i ] == ' ( ' ) a [ i ] = a [ i - 1 ] + 1 ; else a [ i ] = a [ i - 1 ] - 1 ; if ( a [ i ] < 0 ) ans += abs ( a [ i ] ) ; } return ans ; } int main ( ) { string s ; s = \\\" ) ) ) ( ( ( \\\" ; cout << costToBalance ( s ) << endl ; s = \\\" ) ) ( ( \\\" ; cout << costToBalance ( s ) << endl ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Minimum operations to convert Binary Matrix A to B by flipping submatrix of size K | Java program for the above approach ; Function to count the operations required to convert matrix A to B ; Store the sizes of matrix ; Stores count of flips required ; Traverse the iven matrix ; Check if the matrix values are not equal ; Increment the count of moves ; Check if the current square sized exists or not ; Flip all the bits in this square sized submatrix ; Count of operations required ; Driver Code\\\"\\nSolution in Java:\",\"targets\":\"public class GFG { static int minMoves ( char a [ ] [ ] , char b [ ] [ ] , int K ) { int n = a . length ; int m = a [ 0 ] . length ; int cntOperations = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( a [ i ] [ j ] != b [ i ] [ j ] ) { cntOperations ++ ; if ( i + K - 1 >= n j + K - 1 >= m ) { return - 1 ; } for ( int p = 0 ; p <= K - 1 ; p ++ ) { for ( int q = 0 ; q <= K - 1 ; q ++ ) { if ( a [ i + p ] [ j + q ] == '0' ) { a [ i + p ] [ j + q ] = '1' ; } else { a [ i + p ] [ j + q ] = '0' ; } } } } } } return cntOperations ; } public static void main ( String [ ] args ) { char A [ ] [ ] = { { '1' , '0' , '0' } , { '0' , '0' , '0' } , { '0' , '0' , '0' } } ; char B [ ] [ ] = { { '0' , '0' , '0' } , { '0' , '0' , '0' } , { '0' , '0' , '0' } } ; int K = 3 ; System . out . println ( minMoves ( A , B , K ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Compute maximum of the function efficiently over all sub | Java implementation of the approach ; Function to return maximum sum of a sub - array ; Function to return maximum value of function F ; Compute arrays B [ ] and C [ ] ; Find maximum sum sub - array of both of the arrays and take maximum among them ; Driver code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { static int MAX = 100005 ; static int kadaneAlgorithm ( int [ ] ar , int n ) { int sum = 0 , maxSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += ar [ i ] ; if ( sum < 0 ) sum = 0 ; maxSum = Math . max ( maxSum , sum ) ; } return maxSum ; } static int maxFunction ( int [ ] arr , int n ) { int [ ] b = new int [ MAX ] ; int [ ] c = new int [ MAX ] ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( i % 2 == 1 ) { b [ i ] = Math . abs ( arr [ i + 1 ] - arr [ i ] ) ; c [ i ] = - b [ i ] ; } else { c [ i ] = Math . abs ( arr [ i + 1 ] - arr [ i ] ) ; b [ i ] = - c [ i ] ; } } int ans = kadaneAlgorithm ( b , n - 1 ) ; ans = Math . max ( ans , kadaneAlgorithm ( c , n - 1 ) ) ; return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 5 , 4 , 7 } ; int n = arr . length ; System . out . println ( maxFunction ( arr , n ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Write a program to calculate pow ( x , n ) | Javascript code for extended version of power function that can work for var x and negative y ; Driver code\\\"\\nSolution in Javascript:\",\"targets\":\"function power ( x , y ) { var temp ; if ( y == 0 ) return 1 ; temp = power ( x , parseInt ( y \\/ 2 ) ) ; if ( y % 2 == 0 ) return temp * temp ; else { if ( y > 0 ) return x * temp * temp ; else return ( temp * temp ) \\/ x ; } } var x = 2 ; var y = - 3 ; document . write ( power ( x , y ) . toFixed ( 6 ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Minimum number of coins that can generate all the values in the given range | C # implementation of the above approach ; Function to return the count of minimum coins required ; To store the required sequence ; Creating list of the sum of all previous bit values including that bit value ; Driver Code\\\"\\nSolution in C#:\",\"targets\":\"using System ; using System . Collections . Generic ; class GFG { static int findCount ( int N ) { List < int > list = new List < int > ( ) ; int sum = 0 ; int i ; for ( i = 0 ; i < 20 ; i ++ ) { sum += ( int ) Math . Pow ( 2 , i ) ; list . Add ( sum ) ; } for ( i = 0 ; i < 20 ; i ++ ) { if ( ( int ) list [ i ] >= N ) return ( i + 1 ) ; } return 0 ; } public static void Main ( String [ ] args ) { int N = 10 ; Console . WriteLine ( findCount ( N ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"Program to find HCF ( Highest Common Factor ) of 2 Numbers | C program to find GCD of two numbers ; Recursive function to return gcd of a and b ; Driver program to test above function\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } int main ( ) { int a = 98 , b = 56 ; printf ( \\\" GCD ▁ of ▁ % d ▁ and ▁ % d ▁ is ▁ % d ▁ \\\" , a , b , gcd ( a , b ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Subsequence X of length K such that gcd ( X [ 0 ] , X [ 1 ] ) + ( X [ 2 ] , X [ 3 ] ) + ... is maximized | Java program to find the sum of the addition of all possible subsets ; Recursive function to find the maximum value of the given recurrence ; If we get K elements ; If we have reached the end and K elements are not there ; If the state has been visited ; Iterate for every element as the next possible element and take the element which gives the maximum answer ; If this element is the first element in the individual pair in the subsequence then simply recurrence with the last element as i - th index ; If this element is the second element in the individual pair , the find gcd with the previous element and add to the answer and recur for the next element ; Driver Code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { static int MAX = 100 ; static int recur ( int ind , int cnt , int last , int a [ ] , int n , int k , int dp [ ] [ ] ) { if ( cnt == k ) return 0 ; if ( ind == n ) return ( int ) - 1e9 ; if ( dp [ ind ] [ cnt ] != - 1 ) return dp [ ind ] [ cnt ] ; int ans = 0 ; for ( int i = ind ; i < n ; i ++ ) { if ( cnt % 2 == 0 ) ans = Math . max ( ans , recur ( i + 1 , cnt + 1 , i , a , n , k , dp ) ) ; else ans = Math . max ( ans , __gcd ( a [ last ] , a [ i ] ) + recur ( i + 1 , cnt + 1 , 0 , a , n , k , dp ) ) ; } return dp [ ind ] [ cnt ] = ans ; } static int __gcd ( int a , int b ) { if ( b == 0 ) return a ; return __gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { int a [ ] = { 4 , 5 , 3 , 7 , 8 , 10 , 9 , 8 } ; int n = a . length ; int k = 4 ; int [ ] [ ] dp = new int [ n ] [ MAX ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < MAX ; j ++ ) { dp [ i ] [ j ] = - 1 ; } } System . out . println ( recur ( 0 , 0 , 0 , a , n , k , dp ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Find the sum of the number of divisors | ; To store the number of divisors ; Function to find the number of divisors of all numbers in the range 1 to n ; For every number 1 to n ; Increase divisors count for every number ; Function to find the sum of divisors ; To store sum ; Count the divisors ; Driver code ; Function call\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; #define N 100005\\n#define mod 1000000007\\nint cnt [ N ] ; void Divisors ( ) { memset ( cnt , 0 , sizeof cnt ) ; for ( int i = 1 ; i < N ; i ++ ) { for ( int j = 1 ; j * i < N ; j ++ ) cnt [ i * j ] ++ ; } } int Sumofdivisors ( int A , int B , int C ) { int sum = 0 ; Divisors ( ) ; for ( int i = 1 ; i <= A ; i ++ ) { for ( int j = 1 ; j <= B ; j ++ ) { for ( int k = 1 ; k <= C ; k ++ ) { int x = i * j * k ; sum += cnt [ x ] ; if ( sum >= mod ) sum -= mod ; } } } return sum ; } int main ( ) { int A = 5 , B = 6 , C = 7 ; cout << Sumofdivisors ( A , B , C ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Minimum time required to fill a cistern using N pipes | Function to calculate the time ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function T_ime ( $ arr , $ n , $ Emptypipe ) { $ fill = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) $ fill += 1 \\/ $ arr [ $ i ] ; $ fill = $ fill - ( 1 \\/ $ Emptypipe ) ; return 1 \\/ $ fill ; } $ arr = array ( 12 , 14 ) ; $ Emptypipe = 30 ; $ n = count ( $ arr ) ; echo ( int ) T_ime ( $ arr , $ n , $ Emptypipe ) . \\\" ▁ Hours \\\" ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Split given isosceles triangle of height H into N equal parts | C # Code for above approach ; Function to divide the isosceles triangle in equal parts by making N - 1 cuts parallel to the base ; Iterate over the range [ 1 , n - 1 ] ; Driver code ; Given N ; Given H ; Function call\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static void findPoint ( int n , int h ) { for ( int i = 1 ; i < n ; i ++ ) Console . Write ( \\\" { 0 : F2 } ▁ \\\" , Math . Sqrt ( i \\/ ( n * 1.0 ) ) * h ) ; } public static void Main ( String [ ] args ) { int n = 3 ; int h = 2 ; findPoint ( n , h ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Program to print ' N ' alphabet using the number pattern from 1 to n | Function to print the desired Alphabet N Pattern ; Declaring the values of Right , Left and Diagonal values ; Main Loop for the rows ; For the left Values ; Spaces for the diagonals ; Condition for the diagonals ; Spaces for the Right Values ; For the right values ; Size of the Pattern ; Calling the function to print the desired Pattern\\\"\\nSolution in php:\",\"targets\":\"< ? php function Alphabet_N_Pattern ( $ N ) { $ index ; $ side_index ; $ size ; $ Right = 1 ; $ Left = 1 ; $ Diagonal = 2 ; for ( $ index = 0 ; $ index < $ N ; $ index ++ ) { echo $ Left ++ ; for ( $ side_index = 0 ; $ side_index < 2 * ( $ index ) ; $ side_index ++ ) echo \\\" ▁ \\\" ; if ( $ index != 0 && $ index != $ N - 1 ) echo $ Diagonal ++ ; else echo \\\" ▁ \\\" ; for ( $ side_index = 0 ; $ side_index < 2 * ( $ N - $ index - 1 ) ; $ side_index ++ ) echo \\\" ▁ \\\" ; echo $ Right ++ ; echo \\\" \\n \\\" ; } } $ Size = 6 ; Alphabet_N_Pattern ( $ Size ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Check a given sentence for a given set of simple grammer rules | C # program to validate a given sentence for a set of rules ; Method to check a given sentence for given rules ; Calculate the length of the string . ; Check that the first character lies in [ A - Z ] . Otherwise return false . ; If the last character is not a full stop ( . ) no need to check further . ; Maintain 2 states . Previous and current state based on which vertex state you are . Initialise both with 0 = start state . ; Keep the index to the next character in the string . ; Loop to go over the string . ; Set states according to the input characters in the string and the rule defined in the description . If current character is [ A - Z ] . Set current state as 0. ; If current character is a space . Set current state as 1. ; If current character is [ a - z ] . Set current state as 2. ; If current state is a dot ( . ) . Set current state as 3. ; Validates all current state with previous state for the rules in the description of the problem . ; If we have reached last state and previous state is not 1 , then check next character . If next character is ' \\\\0' , then return true , else false ; Set previous state as current state before going over to the next character . ; Driver Code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static bool checkSentence ( char [ ] str ) { int len = str . Length ; if ( str [ 0 ] < ' A ' str [ 0 ] > ' Z ' ) return false ; if ( str [ len - 1 ] != ' . ' ) return false ; int prev_state = 0 , curr_state = 0 ; int index = 1 ; while ( index <= str . Length ) { if ( str [ index ] >= ' A ' && str [ index ] <= ' Z ' ) curr_state = 0 ; else if ( str [ index ] == ' ▁ ' ) curr_state = 1 ; else if ( str [ index ] >= ' a ' && str [ index ] <= ' z ' ) curr_state = 2 ; else if ( str [ index ] == ' . ' ) curr_state = 3 ; if ( prev_state == curr_state && curr_state != 2 ) return false ; if ( prev_state == 2 && curr_state == 0 ) return false ; if ( curr_state == 3 && prev_state != 1 ) return ( index + 1 == str . Length ) ; index ++ ; prev_state = curr_state ; } return false ; } public static void Main ( String [ ] args ) { String [ ] str = { \\\" I ▁ love ▁ cinema . \\\" , \\\" The ▁ vertex ▁ is ▁ S . \\\" , \\\" I ▁ am ▁ single . \\\" , \\\" My ▁ name ▁ is ▁ KG . \\\" , \\\" I ▁ lovE ▁ cinema . \\\" , \\\" GeeksQuiz . ▁ is ▁ a ▁ quiz ▁ site . \\\" , \\\" I ▁ love ▁ Geeksquiz ▁ and ▁ Geeksforgeeks . \\\" , \\\" ▁ You ▁ are ▁ my ▁ friend . \\\" , \\\" I ▁ love ▁ cinema \\\" } ; int str_size = str . Length ; int i = 0 ; for ( i = 0 ; i < str_size ; i ++ ) { if ( checkSentence ( str [ i ] . ToCharArray ( ) ) ) Console . WriteLine ( \\\" \\\\\\\" \\\" + str [ i ] + \\\" \\\\\\\" \\\" + \\\" ▁ is ▁ correct \\\" ) ; else Console . WriteLine ( \\\" \\\\\\\" \\\" + str [ i ] + \\\" \\\\\\\" \\\" + \\\" ▁ is ▁ incorrect \\\" ) ; } } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"Program to Convert Radian to Degree | C code to convert radian to degree ; Function for convertion ; Driver Code\\nHow can the above be solved in C?\",\"targets\":\"#include \\ndouble Convert ( double radian ) { double pi = 3.14159 ; return ( radian * ( 180 \\/ pi ) ) ; } int main ( ) { double radian = 5.0 ; double degree = Convert ( radian ) ; printf ( \\\" % .5lf \\\" , degree ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Efficient program to print all prime factors of a given number | Python program to print prime factors ; A function to print all prime factors of a given number n ; Print the number of two 's that divide n ; n must be odd at this point so a skip of 2 ( i = i + 2 ) can be used ; while i divides n , print i ad divide n ; Condition if n is a prime number greater than 2 ; Driver Program to test above function\\\"\\nSolution in Python:\",\"targets\":\"import math\\ndef primeFactors ( n ) :\\n\\twhile n % 2 == 0 :\\n\\t\\tprint 2 ,\\n\\t\\tn = n \\/ 2\\n\\tfor i in range ( 3 , int ( math . sqrt ( n ) ) + 1 , 2 ) :\\n\\t\\twhile n % i == 0 :\\n\\t\\t\\tprint i ,\\n\\t\\t\\tn = n \\/ i\\n\\tif n > 2 :\\n\\t\\tprint n\\nn = 315\\nprimeFactors ( n )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"HCF of array of fractions ( or rational numbers ) | Python 3 program to find HCF of array of ; find hcf of numerator series ; return hcf of numerator ; find lcm of denominator series ; ans contains LCM of arr [ 0 ] [ 1 ] , . . arr [ i ] [ 1 ] ; return lcm of denominator ; Core Function ; found hcf of numerator ; found lcm of denominator ; return result ; Driver Code ; Initialize the every row with size 2 ( 1 for numerator and 2 for denominator ) ; function for calculate the result ; print the result\\\"\\nHow can the above be solved in Python?\",\"targets\":\"from math import gcd\\ndef findHcf ( arr , size ) :\\n\\tans = arr [ 0 ] [ 0 ]\\n\\tfor i in range ( 1 , size , 1 ) :\\n\\t\\tans = gcd ( ans , arr [ i ] [ 0 ] )\\n\\treturn ( ans )\\ndef findLcm ( arr , size ) :\\n\\tans = arr [ 0 ] [ 1 ]\\n\\tfor i in range ( 1 , size , 1 ) :\\n\\t\\tans = int ( ( ( ( arr [ i ] [ 1 ] * ans ) ) \\/ ( gcd ( arr [ i ] [ 1 ] , ans ) ) ) )\\n\\treturn ( ans )\\ndef hcfOfFraction ( arr , size ) :\\n\\thcf_of_num = findHcf ( arr , size )\\n\\tlcm_of_deno = findLcm ( arr , size )\\n\\tresult = [ 0 for i in range ( 2 ) ]\\n\\tresult [ 0 ] = hcf_of_num\\n\\tresult [ 1 ] = lcm_of_deno\\n\\ti = int ( result [ 0 ] \\/ 2 )\\n\\twhile ( i > 1 ) :\\n\\t\\tif ( ( result [ 1 ] % i == 0 ) and ( result [ 0 ] % i == 0 ) ) :\\n\\t\\t\\tresult [ 1 ] = int ( result [ 1 ] \\/ i )\\n\\t\\t\\tresult [ 0 ] = ( result [ 0 ] \\/ i )\\n\\treturn ( result )\\nif __name__ == ' _ _ main _ _ ' :\\n\\tsize = 4\\n\\tarr = [ 0 for i in range ( size ) ]\\n\\tfor i in range ( size ) :\\n\\t\\tarr [ i ] = [ 0 for i in range ( 2 ) ]\\n\\tarr [ 0 ] [ 0 ] = 9\\n\\tarr [ 0 ] [ 1 ] = 10\\n\\tarr [ 1 ] [ 0 ] = 12\\n\\tarr [ 1 ] [ 1 ] = 25\\n\\tarr [ 2 ] [ 0 ] = 18\\n\\tarr [ 2 ] [ 1 ] = 35\\n\\tarr [ 3 ] [ 0 ] = 21\\n\\tarr [ 3 ] [ 1 ] = 40\\n\\tresult = hcfOfFraction ( arr , size )\\n\\tprint ( result [ 0 ] , \\\" , \\\" , result [ 1 ] )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Check for Majority Element in a sorted array | C Program to check for majority element in a sorted array ; If x is present in arr [ low ... high ] then returns the index of first occurrence of x , otherwise returns - 1 ; Check if arr [ mid ] is the first occurrence of x . arr [ mid ] is first occurrence if x is one of the following is true : ( i ) mid == 0 and arr [ mid ] = = x ( ii ) arr [ mid - 1 ] < x and arr [ mid ] == x ; This function returns true if the x is present more than n \\/ 2 times in arr [ ] of size n ; Find the index of first occurrence of x in arr [ ] ; If element is not present at all , return false ; check if the element is present more than n \\/ 2 times ; Driver program to check above functions\\\"\\nSolution in C:\",\"targets\":\"# include \\n# include \\nint _binarySearch ( int arr [ ] , int low , int high , int x ) { if ( high >= low ) { int mid = ( low + high ) \\/ 2 ; if ( ( mid == 0 x > arr [ mid - 1 ] ) && ( arr [ mid ] == x ) ) return mid ; else if ( x > arr [ mid ] ) return _binarySearch ( arr , ( mid + 1 ) , high , x ) ; else return _binarySearch ( arr , low , ( mid - 1 ) , x ) ; } return -1 ; } bool isMajority ( int arr [ ] , int n , int x ) { int i = _binarySearch ( arr , 0 , n - 1 , x ) ; if ( i == -1 ) return false ; if ( ( ( i + n \\/ 2 ) <= ( n - 1 ) ) && arr [ i + n \\/ 2 ] == x ) return true ; else return false ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 3 , 3 , 3 , 10 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; int x = 3 ; if ( isMajority ( arr , n , x ) ) printf ( \\\" % d ▁ appears ▁ more ▁ than ▁ % d ▁ times ▁ in ▁ arr [ ] \\\" , x , n \\/ 2 ) ; else printf ( \\\" % d ▁ does ▁ not ▁ appear ▁ more ▁ than ▁ % d ▁ times ▁ in ▁ arr [ ] \\\" , x , n \\/ 2 ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"k | CPP program to find k - th element in the Odd - Even sequence . ; insert all the odd numbers from 1 to n . ; insert all the even numbers from 1 to n . ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int findK ( int n , int k ) { vector < long > a ; for ( int i = 1 ; i < n ; i ++ ) if ( i % 2 == 1 ) a . push_back ( i ) ; for ( int i = 1 ; i < n ; i ++ ) if ( i % 2 == 0 ) a . push_back ( i ) ; return ( a [ k - 1 ] ) ; } int main ( ) { long n = 10 , k = 3 ; cout << findK ( n , k ) << endl ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Minimize the length of string by removing occurrence of only one character | Java program to minimize the length of string by removing occurrence of only one character ; Function to find the minimum length ; Count the frequency of each alphabet ; Find the alphabets with maximum frequency ; Subtract the frequency of character from length of string ; Driver Code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . io . * ; class GFG { static int minimumLength ( String s ) { int maxOcc = 0 , n = s . length ( ) ; int arr [ ] = new int [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ s . charAt ( i ) - ' a ' ] ++ ; for ( int i = 0 ; i < 26 ; i ++ ) if ( arr [ i ] > maxOcc ) maxOcc = arr [ i ] ; return ( n - maxOcc ) ; } public static void main ( String [ ] args ) { String str = \\\" afddewqd \\\" ; System . out . println ( minimumLength ( str ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Print all the permutation of length L using the elements of an array | Iterative | C ++ implementation ; Convert the number to Lth base and print the sequence ; Sequence is of length L ; Print the ith element of sequence ; Print all the permuataions ; There can be ( len ) ^ l permutations ; Convert i to len th base ; Driver code ; function call\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; void convert_To_Len_th_base ( int n , int arr [ ] , int len , int L ) { for ( int i = 0 ; i < L ; i ++ ) { cout << arr [ n % len ] ; n \\/= len ; } cout << endl ; } void print ( int arr [ ] , int len , int L ) { for ( int i = 0 ; i < ( int ) pow ( len , L ) ; i ++ ) { convert_To_Len_th_base ( i , arr , len , L ) ; } } int main ( ) { int arr [ ] = { 1 , 2 , 3 } ; int len = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; int L = 2 ; print ( arr , len , L ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Bitwise Operators in C \\/ C ++ |\\\"\\nSolution in C:\",\"targets\":\"#include \\nint main ( ) { int x = 2 , y = 5 ; ( x & y ) ? printf ( \\\" True ▁ \\\" ) : printf ( \\\" False ▁ \\\" ) ; ( x && y ) ? printf ( \\\" True ▁ \\\" ) : printf ( \\\" False ▁ \\\" ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"Find the minimum element in a sorted and rotated array | C program to find minimum element in a sorted and rotated array ; This condition is needed to handle the case when array is not rotated at all ; If there is only one element left ; Find mid ; Check if element ( mid + 1 ) is minimum element . Consider the cases like { 3 , 4 , 5 , 1 , 2 } ; Check if mid itself is minimum element ; Decide whether we need to go to left half or right half ; Driver program to test above functions\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint findMin ( int arr [ ] , int low , int high ) { if ( high < low ) return arr [ 0 ] ; if ( high == low ) return arr [ low ] ; int mid = low + ( high - low ) \\/ 2 ; if ( mid < high && arr [ mid + 1 ] < arr [ mid ] ) return arr [ mid + 1 ] ; if ( mid > low && arr [ mid ] < arr [ mid - 1 ] ) return arr [ mid ] ; if ( arr [ high ] > arr [ mid ] ) return findMin ( arr , low , mid - 1 ) ; return findMin ( arr , mid + 1 , high ) ; } int main ( ) { int arr1 [ ] = { 5 , 6 , 1 , 2 , 3 , 4 } ; int n1 = sizeof ( arr1 ) \\/ sizeof ( arr1 [ 0 ] ) ; printf ( \\\" The ▁ minimum ▁ element ▁ is ▁ % d \\n \\\" , findMin ( arr1 , 0 , n1 - 1 ) ) ; int arr2 [ ] = { 1 , 2 , 3 , 4 } ; int n2 = sizeof ( arr2 ) \\/ sizeof ( arr2 [ 0 ] ) ; printf ( \\\" The ▁ minimum ▁ element ▁ is ▁ % d \\n \\\" , findMin ( arr2 , 0 , n2 - 1 ) ) ; int arr3 [ ] = { 1 } ; int n3 = sizeof ( arr3 ) \\/ sizeof ( arr3 [ 0 ] ) ; printf ( \\\" The ▁ minimum ▁ element ▁ is ▁ % d \\n \\\" , findMin ( arr3 , 0 , n3 - 1 ) ) ; int arr4 [ ] = { 1 , 2 } ; int n4 = sizeof ( arr4 ) \\/ sizeof ( arr4 [ 0 ] ) ; printf ( \\\" The ▁ minimum ▁ element ▁ is ▁ % d \\n \\\" , findMin ( arr4 , 0 , n4 - 1 ) ) ; int arr5 [ ] = { 2 , 1 } ; int n5 = sizeof ( arr5 ) \\/ sizeof ( arr5 [ 0 ] ) ; printf ( \\\" The ▁ minimum ▁ element ▁ is ▁ % d \\n \\\" , findMin ( arr5 , 0 , n5 - 1 ) ) ; int arr6 [ ] = { 5 , 6 , 7 , 1 , 2 , 3 , 4 } ; int n6 = sizeof ( arr6 ) \\/ sizeof ( arr6 [ 0 ] ) ; printf ( \\\" The ▁ minimum ▁ element ▁ is ▁ % d \\n \\\" , findMin ( arr6 , 0 , n6 - 1 ) ) ; int arr7 [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 } ; int n7 = sizeof ( arr7 ) \\/ sizeof ( arr7 [ 0 ] ) ; printf ( \\\" The ▁ minimum ▁ element ▁ is ▁ % d \\n \\\" , findMin ( arr7 , 0 , n7 - 1 ) ) ; int arr8 [ ] = { 2 , 3 , 4 , 5 , 6 , 7 , 8 , 1 } ; int n8 = sizeof ( arr8 ) \\/ sizeof ( arr8 [ 0 ] ) ; printf ( \\\" The ▁ minimum ▁ element ▁ is ▁ % d \\n \\\" , findMin ( arr8 , 0 , n8 - 1 ) ) ; int arr9 [ ] = { 3 , 4 , 5 , 1 , 2 } ; int n9 = sizeof ( arr9 ) \\/ sizeof ( arr9 [ 0 ] ) ; printf ( \\\" The ▁ minimum ▁ element ▁ is ▁ % d \\n \\\" , findMin ( arr9 , 0 , n9 - 1 ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"Find repeated character present first in a string | C program to find the first character that is repeated ; this is O ( N ^ 2 ) method ; Driver code\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#include \\nint findRepeatFirstN2 ( char * s ) { int p = -1 , i , j ; for ( i = 0 ; i < strlen ( s ) ; i ++ ) { for ( j = i + 1 ; j < strlen ( s ) ; j ++ ) { if ( s [ i ] == s [ j ] ) { p = i ; break ; } } if ( p != -1 ) break ; } return p ; } int main ( ) { char str [ ] = \\\" geeksforgeeks \\\" ; int pos = findRepeatFirstN2 ( str ) ; if ( pos == -1 ) printf ( \\\" Not ▁ found \\\" ) ; else printf ( \\\" % c \\\" , str [ pos ] ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"Matrix Chain Multiplication | DP | A naive recursive implementation that simply follows the above optimal substructure property ; Matrix Ai has dimension p [ i - 1 ] x p [ i ] for i = 1. . n ; place parenthesis at different places between first and last matrix , recursively calculate count of multiplications for each parenthesis placement and return the minimum count ; Return minimum count ; Driver code\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#include \\nint MatrixChainOrder ( int p [ ] , int i , int j ) { if ( i == j ) return 0 ; int k ; int min = INT_MAX ; int count ; for ( k = i ; k < j ; k ++ ) { count = MatrixChainOrder ( p , i , k ) + MatrixChainOrder ( p , k + 1 , j ) + p [ i - 1 ] * p [ k ] * p [ j ] ; if ( count < min ) min = count ; } return min ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 3 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; printf ( \\\" Minimum ▁ number ▁ of ▁ multiplications ▁ is ▁ % d ▁ \\\" , MatrixChainOrder ( arr , 1 , n - 1 ) ) ; getchar ( ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Count array elements whose all distinct digits appear in K | C # program for the above approach ; Function to check a digit occurs in the digit of K or not ; Iterate over all possible digits of K ; If current digit equal to digit ; Update K ; Function to find the count of array elements whose distinct digits are a subset of digits of K ; Stores count of array elements whose distinct digits are subset of digits of K ; Traverse the array , [ ] arr ; Stores the current element ; Check if all the digits arr [ i ] is a subset of the digits of K or not ; Iterate over all possible digits of arr [ i ] ; Stores current digit ; If current digit does not appear in K ; Update flag ; Update no ; If all the digits arr [ i ] appear in K ; Update count ; Finally print count ; Driver Code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static bool isValidDigit ( int digit , int K ) { while ( K != 0 ) { if ( K % 10 == digit ) { return true ; } K = K \\/ 10 ; } return false ; } static int noOfValidNumbers ( int K , int [ ] arr ) { int count = 0 ; for ( int i = 0 ; i < arr . Length ; i ++ ) { int no = arr [ i ] ; bool flag = true ; while ( no != 0 ) { int digit = no % 10 ; if ( ! isValidDigit ( digit , K ) ) { flag = false ; break ; } no = no \\/ 10 ; } if ( flag == true ) { count ++ ; } } return count ; } public static void Main ( String [ ] args ) { int K = 12 ; int [ ] arr = { 1 , 12 , 1222 , 13 , 2 } ; Console . WriteLine ( noOfValidNumbers ( K , arr ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Maximize number of days for which P chocolates can be distributed consecutively to N people | C # program to implement the above approach ; Stores the frequency of each type of chocolate ; Function to check if chocolates can be eaten for ' mid ' no . of days ; If cnt exceeds N , return true ; Function to find the maximum number of days for which chocolates can be eaten ; Store the frequency of each type of chocolate ; Initialize start and end with 0 and P respectively ; Calculate mid ; Check if chocolates can be distributed for mid days ; Check if chocolates can be distributed for more than mid consecutive days ; Driver code ; Function call\\\"\\nSolution in C#:\",\"targets\":\"using System ; using System . Collections . Generic ; class GFG { static Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; static int N , P ; static bool helper ( int mid ) { int cnt = 0 ; foreach ( KeyValuePair < int , int > i in mp ) { int temp = i . Value ; while ( temp >= mid ) { temp -= mid ; cnt ++ ; } } return cnt >= N ; } static int findMaximumDays ( int [ ] arr ) { for ( int i = 0 ; i < P ; i ++ ) { if ( mp . ContainsKey ( arr [ i ] ) ) { mp [ arr [ i ] ] = mp [ arr [ i ] ] + 1 ; } else { mp . Add ( arr [ i ] , 1 ) ; } } int start = 0 , end = P , ans = 0 ; while ( start <= end ) { int mid = start + ( ( end - start ) \\/ 2 ) ; if ( mid != 0 && helper ( mid ) ) { ans = mid ; start = mid + 1 ; } else if ( mid == 0 ) { start = mid + 1 ; } else { end = mid - 1 ; } } return ans ; } public static void Main ( String [ ] args ) { N = 3 ; P = 10 ; int [ ] arr = { 1 , 2 , 2 , 1 , 1 , 3 , 3 , 3 , 2 , 4 } ; Console . Write ( findMaximumDays ( arr ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Sum of all the Composite Numbers from Odd indices of the given array | Function to check for composite numbers ; Check if the factors are greater than 2 ; Check if the number is composite or not ; Function to print the sum of all composite numbers in the array ; Iterate for odd indices in the array ; Check if the number is composite then add it to sum ; return the sum ; Driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function composite ( n ) { let flag = 0 ; let c = 0 ; for ( let j = 1 ; j <= n ; j ++ ) { if ( n % j == 0 ) { c += 1 ; } } if ( c >= 3 ) flag = 1 ; return flag ; } function odd_indices ( arr , n ) { let sum = 0 ; for ( let k = 0 ; k < n ; k += 2 ) { let check = composite ( arr [ k ] ) ; if ( check == 1 ) sum += arr [ k ] ; } document . write ( sum + \\\" \\\" ) ; } let arr = [ 13 , 5 , 8 , 16 , 25 ] ; let n = arr . length odd_indices ( arr , n ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Minimum sum of two numbers formed from digits of an array | Function to find and return minimum sum of two numbers formed from digits of the array . ; sort the array ; let two numbers be a and b ; fill a and b with every alternate digit of input array ; return the sum ; Driver Code\\\"\\nSolution in Javascript:\",\"targets\":\"function solve ( arr , n ) { arr . sort ( ) ; let a = 0 , b = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( i % 2 != 0 ) a = a * 10 + arr [ i ] ; else b = b * 10 + arr [ i ] ; } return a + b ; } let arr = [ 6 , 8 , 4 , 5 , 2 , 3 ] ; let n = arr . length ; document . write ( \\\" \\\" + solve ( arr , n ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Smallest power of 2 greater than or equal to n | ; Finds next power of two for n . If n itself is a power of two then returns n ; Driver Code\\\"\\nSolution in C:\",\"targets\":\"#include \\nunsigned int nextPowerOf2 ( unsigned int n ) { n -- ; n |= n >> 1 ; n |= n >> 2 ; n |= n >> 4 ; n |= n >> 8 ; n |= n >> 16 ; n ++ ; return n ; } int main ( ) { unsigned int n = 5 ; printf ( \\\" % d \\\" , nextPowerOf2 ( n ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Program to find the value of sin ( nÃƒÆ ’ à † â €™ Ã⠀ à ¢ â ‚¬ â „¢ ÃƒÆ ’ à ¢ â ‚¬¦½ ÃƒÆ ’ à † â €™ à ¢ à ¢ â € š ¬¹ ÃƒÆ ’ à ¢ â ‚¬¦ à ¢ à ¢ â € š ¬ à … â € œ ) | C # Program to find the value of sin ( n ? ) ; This function use to calculate the binomial coefficient upto 15 ; use simple DP to find coefficient ; Function to find the value of cos ( n - theta ) ; find cosTheta from sinTheta ; store required answer ; use to toggle sign in sequence . ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { private static int MAX = 16 ; static long [ , ] nCr = new long [ MAX , MAX ] ; static void binomial ( ) { for ( int i = 0 ; i < MAX ; i ++ ) { for ( int j = 0 ; j <= i ; j ++ ) { if ( j == 0 j == i ) nCr [ i , j ] = 1 ; else nCr [ i , j ] = nCr [ i - 1 , j ] + nCr [ i - 1 , j - 1 ] ; } } } static double findCosNTheta ( double sinTheta , int n ) { double cosTheta = Math . Sqrt ( 1 - sinTheta * sinTheta ) ; double ans = 0 ; long toggle = 1 ; for ( int i = 1 ; i <= n ; i += 2 ) { ans = ans + nCr [ n , i ] * Math . Pow ( cosTheta , n - i ) * Math . Pow ( sinTheta , i ) * toggle ; toggle = toggle * - 1 ; } return ans ; } public static void Main ( ) { binomial ( ) ; double sinTheta = 0.5 ; int n = 10 ; Console . Write ( findCosNTheta ( sinTheta , n ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Make all array elements even by replacing any pair of array elements with their sum | C ++ program for the above approach ; Function to find the minimum number of replacements required to make all array elements even ; Stores the count of odd elements ; Traverse the array ; Increase count of odd elements ; Store number of replacements required ; Two extra moves will be required to make the last odd element even ; Print the minimum replacements ; Driver Code ; Function call\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; void minMoves ( int arr [ ] , int N ) { int odd_element_cnt = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] % 2 != 0 ) { odd_element_cnt ++ ; } } int moves = ( odd_element_cnt ) \\/ 2 ; if ( odd_element_cnt % 2 != 0 ) moves += 2 ; cout << moves ; } int main ( ) { int arr [ ] = { 5 , 6 , 3 , 7 , 20 } ; int N = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; minMoves ( arr , N ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Sum of elements in an array having prime frequency | Function to create Sieve to check primes ; False here indicates that it is not prime ; If prime [ p ] is not changed , then it is a prime ; Update all multiples of p , set them to non - prime ; Function to return the sum of elements in an array having prime frequency ; Map is used to store element frequencies ; Traverse the map using iterators ; Count the number of elements having prime frequencies ; Driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function SieveOfEratosthenes ( prime , p_size ) { prime [ 0 ] = false ; prime [ 1 ] = false ; for ( let p = 2 ; p * p <= p_size ; p ++ ) { if ( prime [ p ] ) { for ( let i = p * 2 ; i <= p_size ; i += p ) prime [ i ] = false ; } } } function sumOfElements ( arr , n ) { let prime = new Array ( n + 1 ) ; prime . fill ( true ) SieveOfEratosthenes ( prime , n + 1 ) ; let i , j ; let m = new Map ( ) ; for ( i = 0 ; i < n ; i ++ ) { if ( m . has ( arr [ i ] ) ) m . set ( arr [ i ] , m . get ( arr [ i ] ) + 1 ) ; else m . set ( arr [ i ] , 1 ) ; } let sum = 0 ; for ( let it of m ) { if ( prime [ it [ 1 ] ] ) { sum += ( it [ 0 ] ) ; } } return sum ; } let arr = [ 5 , 4 , 6 , 5 , 4 , 6 ] ; let n = arr . length ; document . write ( sumOfElements ( arr , n ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Minimum replacements required to obtain a K | C ++ program for the above approach ; Function to find the minimum number of changes to make the string K - periodic and palindrome ; Initialize ans with 0 ; Iterate from 0 to ( K + 1 ) \\/ 2 ; Store frequency of character ; Iterate through all indices , i , i + K , i + 2 k ... . and store the frequency of character ; Increase the frequency of current character ; Iterate through all indices K - i , 2 K - i , 3 K - i ... . and store the frequency of character ; If K is odd & i is samw as K \\/ 2 , break the loop ; Increase the frequency of current character ; Find the maximum frequency of a character among all visited characters ; If K is odd and i is same as K \\/ 2 then , only N \\/ K characters is visited ; Otherwise N \\/ K * 2 characters has visited ; Return the result ; Driver Code ; Function Call\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int findMinimumChanges ( int N , int K , string S ) { int ans = 0 ; for ( int i = 0 ; i < ( K + 1 ) \\/ 2 ; i ++ ) { map < char , int > mp ; for ( int j = i ; j < N ; j += K ) { mp [ S [ j ] ] ++ ; } for ( int j = N - i - 1 ; j >= 0 ; j -= K ) { if ( K & 1 and i == K \\/ 2 ) break ; mp [ S [ j ] ] ++ ; } int curr_max = INT_MIN ; for ( auto p : mp ) curr_max = max ( curr_max , p . second ) ; if ( K & 1 and i == K \\/ 2 ) ans += ( N \\/ K - curr_max ) ; else ans += ( N \\/ K * 2 - curr_max ) ; } return ans ; } int main ( ) { string S = \\\" aabbcbbcb \\\" ; int N = S . length ( ) ; int K = 3 ; cout << findMinimumChanges ( N , K , S ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Check if given number is Emirp Number or not | Returns true if n is prime else false ; Corner case ; Check from 2 to n - 1 ; Function will check whether number is Emirp or not ; Check if n is prime ; Find reverse of n ; If both Original and Reverse are Prime , then it is an Emirp number ; Input number\\\"\\nSolution in php:\",\"targets\":\"< ? php function isPrime ( $ n ) { if ( $ n <= 1 ) return -1 ; for ( $ i = 2 ; $ i < $ n ; $ i ++ ) if ( $ n % $ i == 0 ) return -1 ; return 1 ; } function isEmirp ( $ n ) { if ( isPrime ( $ n ) == -1 ) return -1 ; $ rev = 0 ; while ( $ n != 0 ) { $ d = $ n % 10 ; $ rev = $ rev * 10 + $ d ; $ n \\/= 10 ; } return isPrime ( $ rev ) ; } $ n = 13 ; if ( isEmirp ( $ n ) == -1 ) echo \\\" Yes \\\" ; else echo \\\" No \\\" ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Rearrange positive and negative numbers with constant extra space | Java implementation of the above approach ; Loop until arr [ i ] < 0 and still inside the array ; Loop until arr [ j ] > 0 and still inside the array ; if i is less than j ; Driver Code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . io . * ; class GFG { public static void RearrangePosNeg ( int arr [ ] ) { int i = 0 ; int j = arr . length - 1 ; while ( true ) { while ( arr [ i ] < 0 && i < arr . length ) i ++ ; while ( arr [ j ] > 0 && j >= 0 ) j -- ; if ( i < j ) { int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; } else break ; } } public static void main ( String [ ] args ) { int arr [ ] = { - 12 , 11 , - 13 , - 5 , 6 , - 7 , 5 , - 3 , - 6 } ; RearrangePosNeg ( arr ) ; for ( int i = 0 ; i < arr . length ; i ++ ) System . out . print ( arr [ i ] + \\\" ▁ \\\" ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Count of numbers from the range [ L , R ] which contains at least one digit that divides K | C ++ implementation of the approach ; Function that returns true if num contains at least one digit that divides k ; Get the last digit ; If the digit is non - zero and it divides k ; Remove the last digit ; There is no digit in num that divides k ; Function to return the required count of elements from the given range which contain at least one digit that divides k ; To store the result ; For every number from the range ; If any digit of the current number divides k ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; bool digitDividesK ( int num , int k ) { while ( num ) { int d = num % 10 ; if ( d != 0 and k % d == 0 ) return true ; num = num \\/ 10 ; } return false ; } int findCount ( int l , int r , int k ) { int count = 0 ; for ( int i = l ; i <= r ; i ++ ) { if ( digitDividesK ( i , k ) ) count ++ ; } return count ; } int main ( ) { int l = 20 , r = 35 ; int k = 45 ; cout << findCount ( l , r , k ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Program to print the Sum of series | Java program to find SUM upto N - th term of the series : - 1 , 2 , 11 , 26 , 47 , 74 , ... . . ; calculate Nth term of series ; driver function ; Get the value of N ; Get the sum of the series\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class solution { static int findSum ( int N ) { return ( N * ( N + 1 ) * ( 2 * N - 5 ) + 4 * N ) \\/ 2 ; } public static void main ( String arr [ ] ) { int N = 3 ; System . out . println ( findSum ( N ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Number is divisible by 29 or not | Returns true if n is divisible by 29 else returns false . ; add the lastdigit * 3 to remaining number until number becomes of only 2 digit ; return true if number is divisible by 29 another ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function isDivisible ( $ n ) { while ( intval ( $ n \\/ 100 ) ) { $ last_digit = $ n % 10 ; $ n = intval ( $ n \\/ 10 ) ; $ n += $ last_digit * 3 ; } return ( $ n % 29 == 0 ) ; } $ n = 348 ; if ( isDivisible ( $ n ) ) echo \\\" Yes \\\" ; else echo \\\" No \\\" ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Find M such that GCD of M and given number N is maximum | C # program for the above approach ; Function to find the integer M such that gcd ( N , M ) is maximum ; Initialize a variable ; Find all the divisors of N and return the maximum divisor ; Check if i is divisible by N ; Update max_gcd ; Return the maximum value ; Driver Code ; Given Number ; Function Call\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int findMaximumGcd ( int n ) { int max_gcd = 1 ; for ( int i = 1 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { if ( i > max_gcd ) max_gcd = i ; if ( ( n \\/ i != i ) && ( n \\/ i != n ) && ( ( n \\/ i ) > max_gcd ) ) max_gcd = n \\/ i ; } } return max_gcd ; } public static void Main ( String [ ] args ) { int N = 10 ; Console . Write ( findMaximumGcd ( N ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Palindromic strings of length 3 possible by using characters of a given string | C ++ program for the above approach ; Function to print all palindromic strings of length 3 that can be formed using characters of string S ; Stores the count of character ; Traverse the string S ; Stores all palindromic strings ; Iterate over the charchaters over the range [ ' a ' , ' z ' ] ; If Hash [ ch ] is equal to 2 ; Iterate over the characters over the range [ ' a ' , ' z ' ] ; Stores all the palindromic string ; Push the s into the set st ; If Hash [ i ] is greater than or equal to 3 ; Iterate over charchaters over the range [ ' a ' , ' z ' ] ; Stores all the palindromic string ; If Hash [ j ] is positive ; Push s into the set st ; Iterate over the set ; Driver Code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; void generatePalindrome ( string S ) { unordered_map < char , int > Hash ; for ( auto ch : S ) { Hash [ ch ] ++ ; } set < string > st ; for ( char i = ' a ' ; i <= ' z ' ; i ++ ) { if ( Hash [ i ] == 2 ) { for ( char j = ' a ' ; j <= ' z ' ; j ++ ) { string s = \\\" \\\" ; if ( Hash [ j ] && i != j ) { s += i ; s += j ; s += i ; st . insert ( s ) ; } } } if ( Hash [ i ] >= 3 ) { for ( char j = ' a ' ; j <= ' z ' ; j ++ ) { string s = \\\" \\\" ; if ( Hash [ j ] ) { s += i ; s += j ; s += i ; st . insert ( s ) ; } } } } for ( auto ans : st ) { cout << ans << \\\" \\n \\\" ; } } int main ( ) { string S = \\\" ddabdac \\\" ; generatePalindrome ( S ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Bubble Sort | An optimized version of Bubble Sort ; traverse the array from 0 to n - i - 1. Swap if the element found is greater than the next element ; IF no two elements were swapped by inner loop , then break ; Driver code to test above\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function bubbleSort ( & $ arr ) { $ n = sizeof ( $ arr ) ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { $ swapped = False ; for ( $ j = 0 ; $ j < $ n - $ i - 1 ; $ j ++ ) { if ( $ arr [ $ j ] > $ arr [ $ j + 1 ] ) { $ t = $ arr [ $ j ] ; $ arr [ $ j ] = $ arr [ $ j + 1 ] ; $ arr [ $ j + 1 ] = $ t ; $ swapped = True ; } } if ( $ swapped == False ) break ; } } $ arr = array ( 64 , 34 , 25 , 12 , 22 , 11 , 90 ) ; $ len = sizeof ( $ arr ) ; bubbleSort ( $ arr ) ; echo \\\" Sorted ▁ array ▁ : ▁ \\n \\\" ; for ( $ i = 0 ; $ i < $ len ; $ i ++ ) echo $ arr [ $ i ] . \\\" ▁ \\\" ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Program to print Step Pattern | Python3 program to print Step Pattern ; function to print the steps ; declare a flag ; traverse through all the characters in the string ; if the x value is 0. . then we must increment till n ... set flag to true ; if the x value is n - 1 then we must decrement till 0 ... set flag as false ; print x * s ; checking whether to increment or decrement x ; Get the String and the number n ; calling the function\\\"\\nSolution in Python:\",\"targets\":\"import math as mt\\ndef steps ( string , n ) :\\n\\tflag = False\\n\\tx = 0\\n\\tfor i in range ( len ( string ) ) :\\n\\t\\tif ( x == 0 ) :\\n\\t\\t\\tflag = True\\n\\t\\tif ( x == n - 1 ) :\\n\\t\\t\\tflag = False\\n\\t\\tfor j in range ( x ) :\\n\\t\\t\\tprint ( \\\" * \\\" , end = \\\" \\\" )\\n\\t\\tprint ( string [ i ] )\\n\\t\\tif ( flag == True ) :\\n\\t\\t\\tx += 1\\n\\t\\telse :\\n\\t\\t\\tx -= 1\\nn = 4\\nstring = \\\" GeeksForGeeks \\\"\\nprint ( \\\" String : ▁ \\\" , string )\\nprint ( \\\" Max ▁ Length ▁ of ▁ Steps : ▁ \\\" , n )\\nsteps ( string , n )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"Mobile Numeric Keypad Problem | A Space Optimized C program to count number of possible numbers of given length ; Return count of all possible numbers of length n in a given numeric keyboard ; odd [ i ] , even [ i ] arrays represent count of numbers starting with digit i for any length j ; for j = 1 ; Bottom Up calculation from j = 2 to n ; Here we are explicitly writing lines for each number 0 to 9. But it can always be written as DFS on 4 X3 grid using row , column array valid moves ; Get count of all possible numbers of length \\\" n \\\" starting with digit 0 , 1 , 2 , ... , 9 ; Driver program to test above function\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint getCount ( char keypad [ ] [ 3 ] , int n ) { if ( keypad == NULL n <= 0 ) return 0 ; if ( n == 1 ) return 10 ; int odd [ 10 ] , even [ 10 ] ; int i = 0 , j = 0 , useOdd = 0 , totalCount = 0 ; for ( i = 0 ; i <= 9 ; i ++ ) odd [ i ] = 1 ; for ( j = 2 ; j <= n ; j ++ ) { useOdd = 1 - useOdd ; if ( useOdd == 1 ) { even [ 0 ] = odd [ 0 ] + odd [ 8 ] ; even [ 1 ] = odd [ 1 ] + odd [ 2 ] + odd [ 4 ] ; even [ 2 ] = odd [ 2 ] + odd [ 1 ] + odd [ 3 ] + odd [ 5 ] ; even [ 3 ] = odd [ 3 ] + odd [ 2 ] + odd [ 6 ] ; even [ 4 ] = odd [ 4 ] + odd [ 1 ] + odd [ 5 ] + odd [ 7 ] ; even [ 5 ] = odd [ 5 ] + odd [ 2 ] + odd [ 4 ] + odd [ 8 ] + odd [ 6 ] ; even [ 6 ] = odd [ 6 ] + odd [ 3 ] + odd [ 5 ] + odd [ 9 ] ; even [ 7 ] = odd [ 7 ] + odd [ 4 ] + odd [ 8 ] ; even [ 8 ] = odd [ 8 ] + odd [ 0 ] + odd [ 5 ] + odd [ 7 ] + odd [ 9 ] ; even [ 9 ] = odd [ 9 ] + odd [ 6 ] + odd [ 8 ] ; } else { odd [ 0 ] = even [ 0 ] + even [ 8 ] ; odd [ 1 ] = even [ 1 ] + even [ 2 ] + even [ 4 ] ; odd [ 2 ] = even [ 2 ] + even [ 1 ] + even [ 3 ] + even [ 5 ] ; odd [ 3 ] = even [ 3 ] + even [ 2 ] + even [ 6 ] ; odd [ 4 ] = even [ 4 ] + even [ 1 ] + even [ 5 ] + even [ 7 ] ; odd [ 5 ] = even [ 5 ] + even [ 2 ] + even [ 4 ] + even [ 8 ] + even [ 6 ] ; odd [ 6 ] = even [ 6 ] + even [ 3 ] + even [ 5 ] + even [ 9 ] ; odd [ 7 ] = even [ 7 ] + even [ 4 ] + even [ 8 ] ; odd [ 8 ] = even [ 8 ] + even [ 0 ] + even [ 5 ] + even [ 7 ] + even [ 9 ] ; odd [ 9 ] = even [ 9 ] + even [ 6 ] + even [ 8 ] ; } } totalCount = 0 ; if ( useOdd == 1 ) { for ( i = 0 ; i <= 9 ; i ++ ) totalCount += even [ i ] ; } else { for ( i = 0 ; i <= 9 ; i ++ ) totalCount += odd [ i ] ; } return totalCount ; } int main ( ) { char keypad [ 4 ] [ 3 ] = { { '1' , '2' , '3' } , { '4' , '5' , '6' } , { '7' , '8' , '9' } , { ' * ' , '0' , ' # ' } } ; printf ( \\\" Count ▁ for ▁ numbers ▁ of ▁ length ▁ % d : ▁ % dn \\\" , 1 , getCount ( keypad , 1 ) ) ; printf ( \\\" Count ▁ for ▁ numbers ▁ of ▁ length ▁ % d : ▁ % dn \\\" , 2 , getCount ( keypad , 2 ) ) ; printf ( \\\" Count ▁ for ▁...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"Find the n | C program to find n - th number whose binary representation is palindrome . ; Finds if the kth bit is set in the binary representation ; Returns the position of leftmost set bit in the binary representation ; Finds whether the integer in binary representation is palindrome or not ; One by one compare bits ; Compare left and right bits and converge ; Start from 1 , traverse through all the integers ; If we reach n , break the loop ; Driver code ; Function Call\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#define INT_MAX 2147483647\\nint isKthBitSet ( int x , int k ) { return ( x & ( 1 << ( k - 1 ) ) ) ? 1 : 0 ; } int leftmostSetBit ( int x ) { int count = 0 ; while ( x ) { count ++ ; x = x >> 1 ; } return count ; } int isBinPalindrome ( int x ) { int l = leftmostSetBit ( x ) ; int r = 1 ; while ( l > r ) { if ( isKthBitSet ( x , l ) != isKthBitSet ( x , r ) ) return 0 ; l -- ; r ++ ; } return 1 ; } int findNthPalindrome ( int n ) { int pal_count = 0 ; int i = 0 ; for ( i = 1 ; i <= INT_MAX ; i ++ ) { if ( isBinPalindrome ( i ) ) { pal_count ++ ; } if ( pal_count == n ) break ; } return i ; } int main ( ) { int n = 9 ; printf ( \\\" % d \\\" , findNthPalindrome ( n ) ) ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Find the maximum possible Binary Number from given string | C # implementation of the approach ; Function to return maximum number that can be formed from the string ; To store the frequency of ' z ' and ' n ' in the given string ; Number of zeroes ; Number of ones ; To store the required number ; Add all the ones ; Add all the zeroes ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static string maxNumber ( string str , int n ) { int [ ] freq = new int [ 2 ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ' z ' ) { freq [ 0 ] ++ ; } else if ( str [ i ] == ' n ' ) { freq [ 1 ] ++ ; } } string num = \\\" \\\" ; for ( int i = 0 ; i < freq [ 1 ] ; i ++ ) num += '1' ; for ( int i = 0 ; i < freq [ 0 ] ; i ++ ) num += '0' ; return num ; } public static void Main ( ) { string str = \\\" roenenzooe \\\" ; int n = str . Length ; Console . Write ( maxNumber ( str , n ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Search an element in a sorted and rotated array | Returns index of key in arr [ l . . h ] if key is present , otherwise returns - 1 ; If arr [ l ... mid ] is sorted ; As this subarray is sorted , we can quickly check if key lies in half or other half ; If key not lies in first half subarray , Divide other half into two subarrays , such that we can quickly check if key lies in other half ; If arr [ l . . mid ] is not sorted , then arr [ mid ... r ] must be sorted ; Driver program\\\"\\nSolution in Python:\",\"targets\":\"def search ( arr , l , h , key ) :\\n\\tif l > h :\\n\\t\\treturn - 1\\n\\tmid = ( l + h ) \\/\\/ 2\\n\\tif arr [ mid ] == key :\\n\\t\\treturn mid\\n\\tif arr [ l ] <= arr [ mid ] :\\n\\t\\tif key >= arr [ l ] and key <= arr [ mid ] :\\n\\t\\t\\treturn search ( arr , l , mid - 1 , key )\\n\\t\\treturn search ( arr , mid + 1 , h , key )\\n\\tif key >= arr [ mid ] and key <= arr [ h ] :\\n\\t\\treturn search ( a , mid + 1 , h , key )\\n\\treturn search ( arr , l , mid - 1 , key )\\narr = [ 4 , 5 , 6 , 7 , 8 , 9 , 1 , 2 , 3 ]\\nkey = 6\\ni = search ( arr , 0 , len ( arr ) - 1 , key )\\nif i != - 1 :\\n\\tprint ( \\\" Index : ▁ % ▁ d \\\" % i )\\nelse :\\n\\tprint ( \\\" Key ▁ not ▁ found \\\" )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Largest factor of a given number which is a perfect square | C # program to find the largest factor of a number which is also a perfect square ; Function to find the largest factor of a given number which is a perfect square ; Initialise the answer to 1 ; Finding the prime factors till sqrt ( num ) ; Frequency of the prime factor in the factorisation initialised to 0 ; If the frequency is odd then multiply i frequency - 1 times to the answer ; Else if it is even , multiply it frequency times ; Driver Code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static double largestSquareFactor ( double num ) { double answer = 1 ; for ( int i = 2 ; i < Math . Sqrt ( num ) ; ++ i ) { int cnt = 0 ; int j = i ; while ( num % j == 0 ) { cnt ++ ; j *= i ; } if ( ( cnt & 1 ) != 0 ) { cnt -- ; answer *= Math . Pow ( i , cnt ) ; } else { answer *= Math . Pow ( i , cnt ) ; } } return answer ; } static public void Main ( ) { int N = 420 ; Console . WriteLine ( largestSquareFactor ( N ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Count Balanced Binary Trees of Height h | Javascript program to count number of balanced binary trees of height h . ; base cases ; Driver program\\\"\\nHow can the above be solved in JS?\",\"targets\":\"let MOD = 1000000007 ; function countBT ( h ) { let dp = new Array ( h + 1 ) ; dp . fill ( 0 ) ; dp [ 0 ] = 1 ; dp [ 1 ] = 1 ; for ( let i = 2 ; i <= h ; ++ i ) dp [ i ] = ( dp [ i - 1 ] * ( ( 2 * dp [ i - 2 ] ) % MOD + dp [ i - 1 ] ) % MOD ) % MOD ; return dp [ h ] ; } let h = 3 ; document . write ( \\\" \\\" + countBT ( h ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Program to duplicate Vowels in String | Java program for printing string with duplicate vowels ; Function to check for the Vowel ; Function to get the resultant string with vowels duplicated ; Another string to store the resultant string ; Loop to check for each character ; Driver Code ; Print the original string ; Print the resultant string\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { static boolean isVowel ( char ch ) { ch = Character . toUpperCase ( ch ) ; return ( ch == ' A ' ch == ' E ' ch == ' I ' ch == ' O ' ch == ' U ' ) ; } static String duplicateVowels ( String str ) { int t = str . length ( ) ; String res = \\\" \\\" ; for ( int i = 0 ; i < t ; i ++ ) { if ( isVowel ( str . charAt ( i ) ) ) res += str . charAt ( i ) ; res += str . charAt ( i ) ; } return res ; } public static void main ( String [ ] args ) { String str = \\\" helloworld \\\" ; System . out . println ( \\\" Original ▁ String : ▁ \\\" + str ) ; String res = duplicateVowels ( str ) ; System . out . println ( \\\" String ▁ with ▁ Vowels ▁ duplicated : ▁ \\\" + res ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Largest subarray with equal number of 0 s and 1 s | A simple program to find the largest subarray with equal number of 0 s and 1 s ; This function Prints the starting and ending indexes of the largest subarray with equal number of 0 s and 1 s . Also returns the size of such subarray . ; Pick a starting point as i ; Consider all subarrays starting from i ; If this is a 0 sum subarray , then compare it with maximum size subarray calculated so far ; Driver program to test above functions\\\"\\nSolution in C:\",\"targets\":\"#include \\nint findSubArray ( int arr [ ] , int n ) { int sum = 0 ; int maxsize = -1 , startindex ; for ( int i = 0 ; i < n - 1 ; i ++ ) { sum = ( arr [ i ] == 0 ) ? -1 : 1 ; for ( int j = i + 1 ; j < n ; j ++ ) { ( arr [ j ] == 0 ) ? ( sum += -1 ) : ( sum += 1 ) ; if ( sum == 0 && maxsize < j - i + 1 ) { maxsize = j - i + 1 ; startindex = i ; } } } if ( maxsize == -1 ) printf ( \\\" No ▁ such ▁ subarray \\\" ) ; else printf ( \\\" % d ▁ to ▁ % d \\\" , startindex , startindex + maxsize - 1 ) ; return maxsize ; } int main ( ) { int arr [ ] = { 1 , 0 , 0 , 1 , 0 , 1 , 1 } ; int size = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; findSubArray ( arr , size ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Check for Majority Element in a sorted array | ; Driver code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def isMajorityElement ( arr , n , key ) :\\n\\tif ( arr [ n \\/\\/ 2 ] == key ) :\\n\\t\\treturn True\\n\\treturn False\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tarr = [ 1 , 2 , 3 , 3 , 3 , 3 , 10 ]\\n\\tn = len ( arr )\\n\\tx = 3\\n\\tif ( isMajorityElement ( arr , n , x ) ) :\\n\\t\\tprint ( x , \\\" ▁ appears ▁ more ▁ than ▁ \\\" , n \\/\\/ 2 , \\\" ▁ times ▁ in ▁ arr [ ] \\\" )\\n\\telse :\\n\\t\\tprint ( x , \\\" ▁ does ▁ not ▁ appear ▁ more ▁ than \\\" , n \\/\\/ 2 , \\\" ▁ times ▁ in ▁ arr [ ] \\\" )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Check if a permutation of S2 can be obtained by adding or removing characters from S1 | C # program for the above approach ; Function to check if the given number is prime or not ; If the number is less than 2 ; If the number is 2 ; If N is a multiple of 2 ; Otherwise , check for the odds values ; Function to check if S1 can be a permutation of S2 by adding or removing characters from S1 ; Initialize a frequency array ; Decrement the frequency for occurrence in s1 ; Increment the frequency for occurence in s2 ; If frequency of current char is same in s1 and s2 ; Check the frequency for the current char is not prime ; Print the result ; Driver Code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { private static bool isPrime ( int n ) { if ( n <= 1 ) return false ; else if ( n == 2 ) return true ; else if ( n % 2 == 0 ) return false ; for ( int i = 3 ; i <= Math . Sqrt ( n ) ; i += 2 ) { if ( n % i == 0 ) return false ; } return true ; } private static void checkPermutation ( string s1 , string s2 ) { int [ ] freq = new int [ 26 ] ; foreach ( char ch in s1 . ToCharArray ( ) ) { freq [ ch - ' a ' ] -- ; } foreach ( char ch in s2 . ToCharArray ( ) ) { freq [ ch - ' a ' ] ++ ; } bool isAllChangesPrime = true ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] == 0 ) { continue ; } else if ( ! isPrime ( Math . Abs ( freq [ i ] ) ) ) { isAllChangesPrime = false ; break ; } } if ( isAllChangesPrime != false ) { Console . WriteLine ( \\\" Yes \\\" ) ; } else { Console . WriteLine ( \\\" No \\\" ) ; } } public static void Main ( String [ ] args ) { string S1 = \\\" gekforgk \\\" ; string S2 = \\\" geeksforgeeks \\\" ; checkPermutation ( S1 , S2 ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Program to Convert Radian to Degree | C code to convert radian to degree ; Function for convertion ; Driver Code\\\"\\nSolution in C:\",\"targets\":\"#include \\ndouble Convert ( double radian ) { double pi = 3.14159 ; return ( radian * ( 180 \\/ pi ) ) ; } int main ( ) { double radian = 5.0 ; double degree = Convert ( radian ) ; printf ( \\\" % .5lf \\\" , degree ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Maximize count of 0 s in left and 1 s in right substring by splitting given Binary string | Java program for the above approach ; Function to maximize the sum of the count of zeros and ones in the left and right substring ; To store the total ones ; Count the total numbers of ones in string str ; To store the count of zeros and ones while traversing string ; Iterate the given string and update the maximum sum ; Update the maximum Sum ; Driver Code ; Given binary string ; Function call\\\"\\nSolution in Java:\",\"targets\":\"import java . util . * ; class GFG { static int maxSum ( String str ) { int maximumSum = 0 ; int totalOnes = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == '1' ) { totalOnes ++ ; } } int zero = 0 , ones = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == '0' ) { zero ++ ; } else { ones ++ ; } maximumSum = Math . max ( maximumSum , zero + ( totalOnes - ones ) ) ; } return maximumSum ; } public static void main ( String args [ ] ) { String str = \\\"011101\\\" ; System . out . println ( maxSum ( str ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Count triplets ( a , b , c ) such that a + b , b + c and a + c are all divisible by K | Set 2 | C ++ program for the above approach ; Function to count the number of triplets from the range [ 1 , N - 1 ] having sum of all pairs divisible by K ; If K is even ; Otherwise ; Driver Code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\\" bits \\/ stdc + + . h \\\"\\nusing namespace std ; int countTriplets ( int N , int K ) { if ( K % 2 == 0 ) { long long int x = N \\/ K ; long long int y = ( N + ( K \\/ 2 ) ) \\/ K ; return x * x * x + y * y * y ; } else { long long int x = N \\/ K ; return x * x * x ; } } int main ( ) { int N = 2 , K = 2 ; cout << countTriplets ( N , K ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Transform the string | Function to change character 's case ; If character is lowercase change to uppercase ; If character is uppercase change to lowercase ; Function to delete vowels ; If character is consonant ; Function to insert \\\" # \\\" ; If character is not special ; Function to transform string ; Driver Code ; Calling function\\\"\\nSolution in php:\",\"targets\":\"< ? php function change_case ( $ a ) { $ l = strlen ( $ a ) ; for ( $ i = 0 ; $ i < $ l ; $ i ++ ) { if ( $ a [ $ i ] >= ' a ' && $ a [ $ i ] <= ' z ' ) $ a [ $ i ] = chr ( 65 + ( ord ( $ a [ $ i ] ) - ord ( ' a ' ) ) ) ; else if ( $ a [ $ i ] >= ' A ' && $ a [ $ i ] <= ' Z ' ) $ a [ $ i ] = chr ( 97 + ( ord ( $ a [ $ i ] ) - ord ( ' a ' ) ) ) ; } return $ a ; } function delete_vowels ( $ a ) { $ temp = \\\" \\\" ; $ l = strlen ( $ a ) ; for ( $ i = 0 ; $ i < $ l ; $ i ++ ) { if ( $ a [ $ i ] != ' a ' && $ a [ $ i ] != ' e ' && $ a [ $ i ] != ' i ' && $ a [ $ i ] != ' o ' && $ a [ $ i ] != ' u ' && $ a [ $ i ] != ' A ' && $ a [ $ i ] != ' E ' && $ a [ $ i ] != ' O ' && $ a [ $ i ] != ' U ' && $ a [ $ i ] != ' I ' ) $ temp = $ temp . $ a [ $ i ] ; } return $ temp ; } function insert_hash ( $ a ) { $ temp = \\\" \\\" ; $ l = strlen ( $ a ) ; for ( $ i = 0 ; $ i < $ l ; $ i ++ ) { if ( ( $ a [ $ i ] >= ' a ' && $ a [ $ i ] <= ' z ' ) || ( $ a [ $ i ] >= ' A ' && $ a [ $ i ] <= ' Z ' ) ) $ temp = $ temp . ' # ' . $ a [ $ i ] ; else $ temp = $ temp . $ a [ $ i ] ; } return $ temp ; } function transformSting ( $ a ) { $ b = delete_vowels ( $ a ) ; $ c = change_case ( $ b ) ; $ d = insert_hash ( $ c ) ; echo ( $ d ) ; } $ a = \\\" SunshinE ! ! \\\" ; transformSting ( $ a ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Sum of multiples of a number up to N | Function for calculating sum of multiples of a upto N ; Number of multiples ; sum of first m natural numbers ; sum of multiples ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function calculate_sum ( $ a , $ N ) { $ m = $ N \\/ $ a ; $ sum = $ m * ( $ m + 1 ) \\/ 2 ; $ ans = $ a * $ sum ; return $ ans ; } $ a = 7 ; $ N = 49 ; echo \\\" Sum ▁ of ▁ multiples ▁ of ▁ \\\" . $ a , \\\" ▁ up ▁ to ▁ \\\" . $ N . \\\" ▁ = ▁ \\\" . calculate_sum ( $ a , $ N ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Count and Print the alphabets having ASCII value in the range [ l , r ] | Function to count the number of characters whose ascii value is in range [ l , r ] ; Initializing the count to 0 ; Increment the count if the value is less ; return the count ; Driver code\\\"\\nSolution in php:\",\"targets\":\"< ? php function CountCharacters ( $ str , $ l , $ r ) { $ cnt = 0 ; $ len = strlen ( $ str ) ; for ( $ i = 0 ; $ i < $ len ; $ i ++ ) { if ( $ l <= ord ( $ str [ $ i ] ) && ord ( $ str [ $ i ] ) <= $ r ) { $ cnt ++ ; echo $ str [ $ i ] . \\\" \\\" ; } } return $ cnt ; } $ str = \\\" geeksforgeeks \\\" ; $ l = 102 ; $ r = 111 ; echo \\\" Characters ▁ with ▁ ASCII ▁ values \\\" . \\\" ▁ in ▁ the ▁ range ▁ [ l , ▁ r ] ▁ are ▁ \\n \\\" ; echo \\\" and their count is \\\" . CountCharacters ( $ str , $ l , $ r ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Maximize Bitwise AND of first element with complement of remaining elements for any permutation of given Array | C # Program to implement the above approach ; Function to maximize the value for the given function and the array elements ; List array to maintain which bit is set for which integer in the given array by saving index of that integer ; Check if j - th bit is set for i - th integer ; Push the index of that integer in setBit [ j ] ; Find the element having highest significant set bit unset in other elements ; Place that integer at 0 - th index ; Store the maximum AND value ; Return the answer ; Driver Code ; Function call\\\"\\nSolution in C#:\",\"targets\":\"using System ; using System . Collections . Generic ; class GFG { static readonly int size_int = 32 ; static int functionMax ( int [ ] arr , int n ) { List < int > [ ] setBit = new List < int > [ 32 + 1 ] ; for ( int i = 0 ; i < setBit . Length ; i ++ ) setBit [ i ] = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < size_int ; j ++ ) { if ( ( arr [ i ] & ( 1 << j ) ) > 0 ) setBit [ j ] . Add ( i ) ; } } for ( int i = size_int ; i >= 0 ; i -- ) { if ( setBit [ i ] . Count == 1 ) { swap ( arr , 0 , setBit [ i ] [ 0 ] ) ; break ; } } int maxAnd = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { maxAnd = maxAnd & ( ~ arr [ i ] ) ; } return maxAnd ; } static int [ ] swap ( int [ ] arr , int i , int j ) { int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; return arr ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 4 , 8 , 16 } ; int n = arr . Length ; Console . Write ( functionMax ( arr , n ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Encrypt string with product of number of vowels and consonants in substring of size k | isVowel ( ) is a function that returns true for a vowel and false otherwise . ; function to Encrypt the dtring ; for each substring ; substring of size k ; counting number of vowels and consonants ; append product to answer . ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function isVowel ( $ c ) { return ( $ c == ' a ' $ c == ' e ' $ c == ' i ' $ c == ' o ' $ c == ' u ' ) ; } function encryptString ( $ s , $ n , $ k ) { $ countVowels = 0 ; $ countConsonants = 0 ; $ ans = \\\" \\\" ; for ( $ l = 0 ; $ l <= $ n - $ k ; $ l ++ ) { $ countVowels = 0 ; $ countConsonants = 0 ; for ( $ r = $ l ; $ r <= $ l + $ k - 1 ; $ r ++ ) { if ( isVowel ( $ s [ $ r ] ) == true ) $ countVowels ++ ; else $ countConsonants ++ ; } $ ans = $ ans . ( string ) ( $ countVowels * $ countConsonants ) ; } return $ ans ; } $ s = \\\" hello \\\" ; $ n = strlen ( $ s ) ; $ k = 2 ; echo encryptString ( $ s , $ n , $ k ) . \\\" \\n \\\" ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Maximum number of elements without overlapping in a Line | Function to find maximum number of elements without overlapping in a line ; If n = 1 , then answer is one ; We can always make 1 st element to cover left segment and nth the right segment ; If left segment for ith element doesnt overlap with i - 1 th element then do left ; else try towards right if possible ; update x [ i ] to right endpoof segment covered by it ; Return the required answer ; Driver code ; Function call\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def Segment ( x , l , n ) :\\n\\tif ( n == 1 ) :\\n\\t\\treturn 1\\n\\tans = 2\\n\\tfor i in range ( 1 , n - 1 ) :\\n\\t\\tif ( x [ i ] - l [ i ] > x [ i - 1 ] ) :\\n\\t\\t\\tans += 1\\n\\t\\telif ( x [ i ] + l [ i ] < x [ i + 1 ] ) :\\n\\t\\t\\tx [ i ] = x [ i ] + l [ i ]\\n\\t\\t\\tans += 1\\n\\treturn ans\\nx = [ 1 , 3 , 4 , 5 , 8 ]\\nl = [ 10 , 1 , 2 , 2 , 5 ]\\nn = len ( x )\\nprint ( Segment ( x , l , n ) )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"Check if array contains contiguous integers with duplicates allowed | Sorting based C ++ implementation to check whether the array contains a set of contiguous integers ; function to check whether the array contains a set of contiguous integers ; Sort the array ; After sorting , check if current element is either same as previous or is one more . ; Driver program to test above\\nHow can the above be solved in C?\",\"targets\":\"#include \\nusing namespace std ; bool areElementsContiguous ( int arr [ ] , int n ) { sort ( arr , arr + n ) ; for ( int i = 1 ; i < n ; i ++ ) if ( arr [ i ] - arr [ i - 1 ] > 1 ) return false ; return true ; } int main ( ) { int arr [ ] = { 5 , 2 , 3 , 6 , 4 , 4 , 6 , 6 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; if ( areElementsContiguous ( arr , n ) ) cout << \\\" Yes \\\" ; else cout << \\\" No \\\" ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Lagrange 's Interpolation | To represent a data point corresponding to x and y = f ( x ) ; function to interpolate the given data points using Lagrange 's formula xi corresponds to the new data point whose value is to be obtained n represents the number of known data points ; let result = 0 ; Initialize result ; Compute individual terms of above formula ; Add current term to result ; creating an array of 4 known data points ; Using the interpolate function to obtain a data point corresponding to x = 3\\\"\\nSolution in Javascript:\",\"targets\":\"class Data { constructor ( x , y ) { this . x = x ; this . y = y ; } } function interpolate ( f , xi , n ) { for ( let i = 0 ; i < n ; i ++ ) { let term = f [ i ] . y ; for ( let j = 0 ; j < n ; j ++ ) { if ( j != i ) term = term * ( xi - f [ j ] . x ) \\/ ( f [ i ] . x - f [ j ] . x ) ; } result += term ; } return result ; } let f = [ new Data ( 0 , 2 ) , new Data ( 1 , 3 ) , new Data ( 2 , 12 ) , new Data ( 5 , 147 ) ] ; document . write ( \\\" \\\" + interpolate ( f , 3 , 4 ) ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Calculate score of a string consisting of balanced parentheses | C # program to implement the above approach ; Function to calculate score of parentheses ; Stores index of character of String ; Stores total scores obtained from the String ; Iterate over characters of the String ; If s [ i ] is ' ( ' ; If top element of stack is ' ( ' ; Stores score of inner parentheses ; Calculate score of inner parentheses ; Update count ; Pop from stack ; Insert score of inner parentheses ; Update i ; Calculate score of the String ; Update ans ; Driver Code\\\"\\nSolution in C#:\",\"targets\":\"using System ; using System . Collections . Generic ; class GFG { static long scoreOfParentheses ( String S ) { Stack < String > s = new Stack < String > ( ) ; int i = 0 ; long ans = 0 ; while ( i < S . Length ) { if ( S [ i ] == ' ( ' ) s . Push ( \\\" ( \\\" ) ; else { if ( s . Peek ( ) == \\\" ( \\\" ) { s . Pop ( ) ; s . Push ( \\\"1\\\" ) ; } else { long count = 0 ; while ( s . Peek ( ) != \\\" ( \\\" ) { count += Int32 . Parse ( s . Peek ( ) ) ; s . Pop ( ) ; } s . Pop ( ) ; s . Push ( String . Join ( \\\" \\\" , 2 * count ) ) ; } } i ++ ; } while ( s . Count != 0 ) { ans += Int32 . Parse ( s . Peek ( ) ) ; s . Pop ( ) ; } return ans ; } public static void Main ( String [ ] args ) { String S1 = \\\" ( ( ) ( ( ) ) ) \\\" ; Console . Write ( scoreOfParentheses ( S1 ) + \\\" \\n \\\" ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"Enneacontagon Number | C program for above approach ; Finding the nth enneacontagon Number ; Driver program to test above function\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#include \\nint enneacontagonNum ( int n ) { return ( 88 * n * n - 86 * n ) \\/ 2 ; } int main ( ) { int n = 3 ; printf ( \\\"3rd ▁ enneacontagon ▁ Number ▁ is ▁ = ▁ % d \\\" , enneacontagonNum ( n ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Count of groups of consecutive 1 s in a given Binary String | C # program for the above approach ; Function to find the number of the groups of 1 s only in the binary string ; Stores number of groups of 1 s ; Initialization of the stack ; Traverse the string S ; If S [ i ] is '1' ; Otherwise ; If st is empty ; If st is not empty ; Return answer ; Driver code ; Input ; Function call\\\"\\nSolution in C#:\",\"targets\":\"using System ; using System . Collections . Generic ; class GFG { static int groupsOfOnes ( string S , int N ) { int count = 0 ; Stack < int > st = new Stack < int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( S [ i ] == '1' ) st . Push ( 1 ) ; else { if ( st . Count > 0 ) { count ++ ; while ( st . Count > 0 ) { st . Pop ( ) ; } } } } if ( st . Count > 0 ) count ++ ; return count ; } public static void Main ( ) { string S = \\\"100110111\\\" ; int N = S . Length ; Console . Write ( groupsOfOnes ( S , N ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Find if a point lies inside a Circle | Python3 program to check if a point lies inside a circle or not ; Compare radius of circle with distance of its center from given point ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def isInside ( circle_x , circle_y , rad , x , y ) :\\n\\tif ( ( x - circle_x ) * ( x - circle_x ) + ( y - circle_y ) * ( y - circle_y ) <= rad * rad ) :\\n\\t\\treturn True ;\\n\\telse :\\n\\t\\treturn False ;\\nx = 1 ;\\ny = 1 ;\\ncircle_x = 0 ;\\ncircle_y = 1 ;\\nrad = 2 ;\\nif ( isInside ( circle_x , circle_y , rad , x , y ) ) :\\n\\tprint ( \\\" Inside \\\" ) ;\\nelse :\\n\\tprint ( \\\" Outside \\\" ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Count of strings that does not contain Arc intersection | Function to check if there is arc intersection or not ; Traverse the string S ; Insert all the elements in the stack one by one ; Extract the top element ; Pop out the top element ; Check if the top element is same as the popped element ; Otherwise ; If the stack is empty ; Function to check if there is arc intersection or not for the given array of strings ; Stores count of string not having arc intersection ; Iterate through array ; Length of every string ; Function Call ; Print the desired count ; Driver Code ; Function Call\\\"\\nSolution in Python:\",\"targets\":\"def arcIntersection ( S , lenn ) :\\n\\tstk = [ ]\\n\\tfor i in range ( lenn ) :\\n\\t\\tstk . append ( S [ i ] )\\n\\t\\tif ( len ( stk ) >= 2 ) :\\n\\t\\t\\ttemp = stk [ - 1 ]\\n\\t\\t\\tdel stk [ - 1 ]\\n\\t\\t\\tif ( stk [ - 1 ] == temp ) :\\n\\t\\t\\t\\tdel stk [ - 1 ]\\n\\t\\t\\telse :\\n\\t\\t\\t\\tstk . append ( temp )\\n\\tif ( len ( stk ) == 0 ) :\\n\\t\\treturn 1\\n\\treturn 0\\ndef countString ( arr , N ) :\\n\\tcount = 0\\n\\tfor i in range ( N ) :\\n\\t\\tlenn = len ( arr [ i ] )\\n\\t\\tcount += arcIntersection ( arr [ i ] , lenn )\\n\\tprint ( count )\\nif __name__ == ' _ _ main _ _ ' :\\n\\tarr = [ \\\"0101\\\" , \\\"0011\\\" , \\\"0110\\\" ]\\n\\tN = len ( arr )\\n\\tcountString ( arr , N )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Given two numbers as strings , find if one is a power of other | C # program to check if one number is power of other ; Multiply the numbers . It multiplies each digit of second string to each digit of first and stores the result . ; If the digit exceeds 9 , add the cumulative carry to previous digit . ; if all zeroes , return \\\"0\\\" . ; Remove starting zeroes . ; Removes Extra zeroes from front of a string . ; Make sure there are no leading zeroes in the string . ; Making sure that s1 is smaller . If it is greater , we recur we reversed parameters . ; Driver Code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; public class new_file { static bool isGreaterThanEqual ( String s1 , String s2 ) { if ( s1 . Length > s2 . Length ) return true ; if ( s1 . CompareTo ( s2 ) == 0 ) return true ; return false ; } static String multiply ( String s1 , String s2 ) { int n = s1 . Length ; int m = s2 . Length ; int i = 0 ; int [ ] result = new int [ n + m ] ; for ( i = n - 1 ; i >= 0 ; i -- ) for ( int j = m - 1 ; j >= 0 ; j -- ) result [ i + j + 1 ] += ( s1 [ i ] - '0' ) * ( s2 [ j ] - '0' ) ; int size = result . Length ; for ( i = size - 1 ; i > 0 ; i -- ) { if ( result [ i ] >= 10 ) { result [ i - 1 ] += result [ i ] \\/ 10 ; result [ i ] = result [ i ] % 10 ; } } i = 0 ; while ( i < size && result [ i ] == 0 ) i ++ ; if ( i == size ) return \\\"0\\\" ; String temp = \\\" \\\" ; while ( i < size ) { temp += ( result [ i ] ) . ToString ( ) ; i ++ ; } return temp ; } static String removeLeadingZeores ( String s ) { int n = s . Length ; int i = 0 ; while ( i < n && s [ i ] == '0' ) i ++ ; if ( i == n ) return \\\"0\\\" ; String temp = \\\" \\\" ; while ( i < n ) { temp += s [ i ] ; i ++ ; } return temp ; } static bool isPower ( String s1 , String s2 ) { s1 = removeLeadingZeores ( s1 ) ; s2 = removeLeadingZeores ( s2 ) ; if ( s1 == \\\"0\\\" s2 == \\\"0\\\" ) return false ; if ( s1 == \\\"1\\\" && s2 == \\\"1\\\" ) return true ; if ( s1 == \\\"1\\\" s2 == \\\"1\\\" ) return true ; if ( s1 . Length > s2 . Length ) return isPower ( s2 , s1 ) ; String temp = s1 ; while ( ! isGreaterThanEqual ( s1 , s2 ) ) s1 = multiply ( s1 , temp ) ; if ( s1 . CompareTo ( s2 ) == 0 ) return true ; return false ; } public static void Main ( String [ ] args ) { String s1 = \\\"374747\\\" , s2 = \\\"52627712618930723\\\" ; if ( isPower ( s1 , s2 ) ) Console . WriteLine ( \\\" Yes \\\" ) ; else Console . WriteLine ( \\\" No \\\" ) ; s1 = \\\"4099\\\" ; s2 = \\\"2\\\" ; if ( isPower ( s1 , s2 ) ) Console . WriteLine ( \\\" Yes \\\" ) ; else Console . WriteLine ( \\\" No \\\" ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Segregate 0 s and 1 s in an array | C program to sort a binary array in one pass ; Function to put all 0 s on left and all 1 s on right ; Initialize left and right indexes ; Increment left index while we see 0 at left ; Decrement right index while we see 1 at right ; If left is smaller than right then there is a 1 at left and a 0 at right . Exchange arr [ left ] and arr [ right ] ; driver program to test\\\"\\nSolution in C:\",\"targets\":\"#include \\nvoid segregate0and1 ( int arr [ ] , int size ) { int left = 0 , right = size - 1 ; while ( left < right ) { while ( arr [ left ] == 0 && left < right ) left ++ ; while ( arr [ right ] == 1 && left < right ) right -- ; if ( left < right ) { arr [ left ] = 0 ; arr [ right ] = 1 ; left ++ ; right -- ; } } } int main ( ) { int arr [ ] = { 0 , 1 , 0 , 1 , 1 , 1 } ; int i , arr_size = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; segregate0and1 ( arr , arr_size ) ; printf ( \\\" Array ▁ after ▁ segregation ▁ \\\" ) ; for ( i = 0 ; i < 6 ; i ++ ) printf ( \\\" % d ▁ \\\" , arr [ i ] ) ; getchar ( ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Distance between two parallel Planes in 3 | Python program to find the Distance between two parallel Planes in 3 D . ; Function to find distance ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"import math\\ndef distance ( a1 , b1 , c1 , d1 , a2 , b2 , c2 , d2 ) :\\n\\tif ( a1 \\/ a2 == b1 \\/ b2 and b1 \\/ b2 == c1 \\/ c2 ) :\\n\\t\\tx1 = y1 = 0\\n\\t\\tz1 = - d1 \\/ c1\\n\\t\\td = abs ( ( c2 * z1 + d2 ) ) \\/ ( math . sqrt ( a2 * a2 + b2 * b2 + c2 * c2 ) )\\n\\t\\tprint ( \\\" Perpendicular ▁ distance ▁ is \\\" ) , d\\n\\telse :\\n\\t\\tprint ( \\\" Planes ▁ are ▁ not ▁ parallel \\\" )\\na1 = 1\\nb1 = 2\\nc1 = - 1\\nd1 = 1\\na2 = 3\\nb2 = 6\\nc2 = - 3\\nd2 = - 4\\ndistance ( a1 , b1 , c1 , d1 , a2 , b2 , c2 , d2 )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Find extra element in the second array | C ++ implementation of the approach ; Function to return the extra element in B [ ] ; To store the result ; Find the XOR of all the element of array A [ ] and array B [ ] ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int extraElement ( int A [ ] , int B [ ] , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) ans ^= A [ i ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) ans ^= B [ i ] ; return ans ; } int main ( ) { int A [ ] = { 10 , 15 , 5 } ; int B [ ] = { 10 , 100 , 15 , 5 } ; int n = sizeof ( A ) \\/ sizeof ( int ) ; cout << extraElement ( A , B , n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Count of triplets in an array that satisfy the given conditions | Python3 implementation of the approach ; All possible solutions of the equation 1 \\/ a + 1 \\/ b + 1 \\/ c = 1 ; Function to find the triplets ; Storing indices of the elements ; Check if y can act as the middle element of triplet with the given solution of 1 \\/ a + 1 \\/ b + 1 \\/ c = 1 ; Binary search to find the number of possible values of the first element ; Binary search to find the number of possible values of the third element ; Contribution to the answer would be the multiplication of the possible values for the first and the third element ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"MAX = 100001\\nROW = 10\\nCOL = 3\\nindices = [ 0 ] * MAX\\ntest = [ [ 2 , 3 , 6 ] , [ 2 , 4 , 4 ] , [ 2 , 6 , 3 ] , [ 3 , 2 , 6 ] , [ 3 , 3 , 3 ] , [ 3 , 6 , 2 ] , [ 4 , 2 , 4 ] , [ 4 , 4 , 2 ] , [ 6 , 2 , 3 ] , [ 6 , 3 , 2 ] ]\\ndef find_triplet ( array , n ) :\\n\\tanswer = 0\\n\\tfor i in range ( MAX ) :\\n\\t\\tindices [ i ] = [ ]\\n\\tfor i in range ( n ) :\\n\\t\\tindices [ array [ i ] ] . append ( i )\\n\\tfor i in range ( n ) :\\n\\t\\ty = array [ i ]\\n\\t\\tfor j in range ( ROW ) :\\n\\t\\t\\ts = test [ j ] [ 1 ] * y\\n\\t\\t\\tif s % test [ j ] [ 0 ] != 0 :\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif s % test [ j ] [ 2 ] != 0 :\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tx = s \\/\\/ test [ j ] [ 0 ]\\n\\t\\t\\tz = s \\/\\/ test [ j ] [ 2 ]\\n\\t\\t\\tif x > MAX or z > MAX :\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tl = 0\\n\\t\\t\\tr = len ( indices [ x ] ) - 1\\n\\t\\t\\tfirst = - 1\\n\\t\\t\\twhile l <= r :\\n\\t\\t\\t\\tm = ( l + r ) \\/\\/ 2\\n\\t\\t\\t\\tif indices [ x ] [ m ] < i :\\n\\t\\t\\t\\t\\tfirst = m\\n\\t\\t\\t\\t\\tl = m + 1\\n\\t\\t\\t\\telse :\\n\\t\\t\\t\\t\\tr = m - 1\\n\\t\\t\\tl = 0\\n\\t\\t\\tr = len ( indices [ z ] ) - 1\\n\\t\\t\\tthird = - 1\\n\\t\\t\\twhile l <= r :\\n\\t\\t\\t\\tm = ( l + r ) \\/\\/ 2\\n\\t\\t\\t\\tif indices [ z ] [ m ] > i :\\n\\t\\t\\t\\t\\tthird = m\\n\\t\\t\\t\\t\\tr = m - 1\\n\\t\\t\\t\\telse :\\n\\t\\t\\t\\t\\tl = m + 1\\n\\t\\t\\tif first != - 1 and third != - 1 :\\n\\t\\t\\t\\tanswer += ( first + 1 ) * ( len ( indices [ z ] ) - third )\\n\\treturn answer\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tarray = [ 2 , 4 , 5 , 6 , 7 ]\\n\\tn = len ( array )\\n\\tprint ( find_triplet ( array , n ) )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"How to validate GUID ( Globally Unique Identifier ) using Regular Expression | C ++ program to validate the GUID ( Globally Unique Identifier ) using Regular Expression ; Function to validate the GUID ( Globally Unique Identifier ) . ; Regex to check valid GUID ( Globally Unique Identifier ) . ; If the GUID ( Globally Unique Identifier ) is empty return false ; Return true if the GUID ( Globally Unique Identifier ) matched the ReGex ; Driver Code ; Test Case 1 : ; Test Case 2 : ; Test Case 3 : ; Test Case 4 :\\\"\\nSolution in C++:\",\"targets\":\"#include \\n#include \\nusing namespace std ; bool isValidGUID ( string str ) { const regex pattern ( \\\" ^ [ { ] ? [ 0-9a - fA - F ] { 8 } - ( [ 0-9a - fA - F ] { 4 } - ) { 3 } [ 0-9a - fA - F ] { 12 } [ } ] ? $ \\\" ) ; if ( str . empty ( ) ) { return false ; } if ( regex_match ( str , pattern ) ) { return true ; } else { return false ; } } int main ( ) { string str1 = \\\"123e4567 - e89b - 12d3 - a456-9AC7CBDCEE52\\\" ; cout << isValidGUID ( str1 ) << endl ; string str2 = \\\" { 123e4567 - e89b - 12d3 - a456-9AC7CBDCEE52 } \\\" ; cout << isValidGUID ( str2 ) << endl ; string str3 = \\\"123e4567 - h89b - 12d3 - a456-9AC7CBDCEE52\\\" ; cout << isValidGUID ( str3 ) << endl ; string str4 = \\\"123e4567 - h89b - 12d3 - a456\\\" ; cout << isValidGUID ( str4 ) << endl ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Rearrange the array to maximize the number of primes in prefix sum of the array | Function to print the re - arranged array ; Count the number of ones and twos in a [ ] ; If the array element is 1 ; Array element is 2 ; If it has at least one 2 Fill up first 2 ; Decrease the cnt of ones if even ; Fill up with odd count of ones ; Fill up with remaining twos ; If even ones , then fill last position ; Print the rearranged array ; Driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function solve ( a , n ) { let ones = 0 , twos = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 1 ) ones ++ ; else twos ++ ; } let ind = 0 ; if ( twos > 0 ) a [ ind ++ ] = 2 ; let evenOnes = ( ones % 2 == 0 ) ? true : false ; if ( evenOnes ) ones -= 1 ; for ( let i = 0 ; i < ones ; i ++ ) a [ ind ++ ] = 1 ; for ( let i = 0 ; i < twos - 1 ; i ++ ) a [ ind ++ ] = 2 ; if ( evenOnes ) a [ ind ++ ] = 1 ; for ( let i = 0 ; i < n ; i ++ ) document . write ( a [ i ] + \\\" \\\" ) ; } let a = [ 1 , 2 , 1 , 2 , 1 ] ; let n = a . length ; solve ( a , n ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Count of integral coordinates that lies inside a Square | C # program for the above approach ; Function to calculate the integral points inside a square ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static void countIntgralPoints ( int x1 , int y1 , int x2 , int y2 ) { Console . WriteLine ( ( y2 - y1 - 1 ) * ( x2 - x1 - 1 ) ) ; } static void Main ( ) { int x1 = 1 , y1 = 1 ; int x2 = 4 , y2 = 4 ; countIntgralPoints ( x1 , y1 , x2 , y2 ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Count quadruples of given type from given array | Java program of the above approach ; Function to find the count of the subsequence of given type ; Stores the count of quadruples ; Generate all possible combinations of quadruples ; Check if 1 st element is equal to 3 rd element ; Check if 2 nd element is equal to 4 th element ; Driver code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { static int countSubsequece ( int a [ ] , int n ) { int i , j , k , l ; int answer = 0 ; for ( i = 0 ; i < n ; i ++ ) { for ( j = i + 1 ; j < n ; j ++ ) { for ( k = j + 1 ; k < n ; k ++ ) { for ( l = k + 1 ; l < n ; l ++ ) { if ( a [ j ] == a [ l ] && a [ i ] == a [ k ] ) { answer ++ ; } } } } } return answer ; } public static void main ( String [ ] args ) { int [ ] a = { 1 , 2 , 3 , 2 , 1 , 3 , 2 } ; System . out . print ( countSubsequece ( a , 7 ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Partition problem | DP | A Dynamic Programming based C program to partition problem ; Returns true if arr [ ] can be partitioned in two subsets of equal sum , otherwise false ; Calculate sum of all elements ; initialize top row as true ; initialize leftmost column , except part [ 0 ] [ 0 ] , as 0 ; Fill the partition table in bottom up manner ; uncomment this part to print table ; Driver code ; Function call\\\"\\nSolution in C:\",\"targets\":\"#include \\nbool findPartiion ( int arr [ ] , int n ) { int sum = 0 ; int i , j ; for ( i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; if ( sum % 2 != 0 ) return false ; bool part [ sum \\/ 2 + 1 ] [ n + 1 ] ; for ( i = 0 ; i <= n ; i ++ ) part [ 0 ] [ i ] = true ; for ( i = 1 ; i <= sum \\/ 2 ; i ++ ) part [ i ] [ 0 ] = false ; for ( i = 1 ; i <= sum \\/ 2 ; i ++ ) { for ( j = 1 ; j <= n ; j ++ ) { part [ i ] [ j ] = part [ i ] [ j - 1 ] ; if ( i >= arr [ j - 1 ] ) part [ i ] [ j ] = part [ i ] [ j ] || part [ i - arr [ j - 1 ] ] [ j - 1 ] ; } } return part [ sum \\/ 2 ] [ n ] ; } int main ( ) { int arr [ ] = { 3 , 1 , 1 , 2 , 2 , 1 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; if ( findPartiion ( arr , n ) == true ) printf ( \\\" Can ▁ be ▁ divided ▁ into ▁ two ▁ subsets ▁ of ▁ equal ▁ sum \\\" ) ; else printf ( \\\" Can ▁ not ▁ be ▁ divided ▁ into ▁ two ▁ subsets ▁ of ▁ \\\" \\\" equal ▁ sum \\\" ) ; getchar ( ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Smallest String consisting of a String S exactly K times as a Substring | C ++ Program to implement the above approach ; KMP algorithm ; Function to return the required string ; Finding the longest proper prefix which is also suffix ; ans string ; Update ans appending the substring K - 1 times ; Append the original string ; Returning min length string which contain exactly k substring of given string ; Driver Code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int * kmp ( string & s ) { int n = s . size ( ) ; int * lps = new int [ n ] ; lps [ 0 ] = 0 ; int i = 1 , len = 0 ; while ( i < n ) { if ( s [ i ] == s [ len ] ) { len ++ ; lps [ i ] = len ; i ++ ; } else { if ( len != 0 ) { len = lps [ len - 1 ] ; } else { lps [ i ] = 0 ; i ++ ; } } } return lps ; } string findString ( string & s , int k ) { int n = s . length ( ) ; int * lps = kmp ( s ) ; string ans = \\\" \\\" ; string suff = s . substr ( 0 , n - lps [ n - 1 ] ) ; for ( int i = 0 ; i < k - 1 ; ++ i ) { ans += suff ; } ans += s ; return ans ; } int main ( ) { int k = 3 ; string s = \\\" geeksforgeeks \\\" ; cout << findString ( s , k ) << endl ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Count the number of ways to construct the target string | C # Program to Count the number of ways to construct the target String ; base case ; If current subproblem has been solved , use the value ; search through all the indiced at which the current character occurs . For each index greater than prev , take the index and move to the next position , and add to the answer . ; Store and return the solution for this subproblem ; preprocess the Strings by storing for each character of every String , the index of their occurrence we will use a common list for all because of only the index matter in the String from which the character was picked ; we are storing j + 1 because the initial picked index in the recursive step will ne 0. This is just for ease of implementation ; initialise dp table . - 1 represents that the subproblem hasn 't been solved ; Driver Code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; using System . Collections . Generic ; class GFG { static int mod = 1000000007 ; static int [ , ] dp = new int [ 1000 , 1000 ] ; static int calculate ( int pos , int prev , String s , List < int > index ) { if ( pos == s . Length ) return 1 ; if ( dp [ pos , prev ] != - 1 ) return dp [ pos , prev ] ; int answer = 0 ; for ( int i = 0 ; i < index . Count ; i ++ ) { if ( index [ i ] . CompareTo ( prev ) >= 0 ) { answer = ( answer % mod + calculate ( pos + 1 , index [ i ] , s , index ) % mod ) % mod ; } } return dp [ pos , prev ] = answer ; } static int countWays ( List < String > a , String s ) { int n = a . Count ; List < int > [ ] index = new List < int > [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) index [ i ] = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < a [ i ] . Length ; j ++ ) { index [ a [ i ] [ j ] - ' a ' ] . Add ( j + 1 ) ; } } for ( int i = 0 ; i < 1000 ; i ++ ) { for ( int j = 0 ; j < 1000 ; j ++ ) { dp [ i , j ] = - 1 ; } } return calculate ( 0 , 0 , s , index [ 0 ] ) ; } public static void Main ( String [ ] args ) { List < String > A = new List < String > ( ) ; A . Add ( \\\" adc \\\" ) ; A . Add ( \\\" aec \\\" ) ; A . Add ( \\\" erg \\\" ) ; String S = \\\" ac \\\" ; Console . Write ( countWays ( A , S ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Maximum count of common divisors of A and B such that all are co | C ++ implementation of the approach ; Function to return the count of common factors of a and b such that all the elements are co - prime to one another ; GCD of a and b ; Include 1 initially ; Find all the prime factors of the gcd ; If gcd is prime ; Return the required answer ; Driver code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int maxCommonFactors ( int a , int b ) { int gcd = __gcd ( a , b ) ; int ans = 1 ; for ( int i = 2 ; i * i <= gcd ; i ++ ) { if ( gcd % i == 0 ) { ans ++ ; while ( gcd % i == 0 ) gcd \\/= i ; } } if ( gcd != 1 ) ans ++ ; return ans ; } int main ( ) { int a = 12 , b = 18 ; cout << maxCommonFactors ( a , b ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Sort 3 numbers | Python3 program to sort an array of size 3 ; Insert arr [ 1 ] ; Insert arr [ 2 ] ; Driver code\\\"\\nSolution in Python:\",\"targets\":\"def sort3 ( arr ) :\\n\\tif ( arr [ 1 ] < arr [ 0 ] ) :\\n\\t\\tarr [ 0 ] , arr [ 1 ] = arr [ 1 ] , arr [ 0 ]\\n\\tif ( arr [ 2 ] < arr [ 1 ] ) :\\n\\t\\tarr [ 1 ] , arr [ 2 ] = arr [ 2 ] , arr [ 1 ]\\n\\t\\tif ( arr [ 1 ] < arr [ 0 ] ) :\\n\\t\\t\\tarr [ 1 ] , arr [ 0 ] = arr [ 0 ] , arr [ 1 ]\\na = [ 10 , 12 , 5 ]\\nsort3 ( a )\\nfor i in range ( 3 ) :\\n\\tprint ( a [ i ] , end = \\\" ▁ \\\" )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Minimum value to be assigned to the elements so that sum becomes greater than initial sum | Function to return the minimum required value ; Find the sum of the array elements ; Return the required value ; Driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function findMinValue ( arr , n ) { let sum = 0 ; for ( let i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; return ( parseInt ( sum \\/ n ) + 1 ) ; } let arr = [ 4 , 2 , 1 , 10 , 6 ] ; let n = arr . length ; document . write ( findMinValue ( arr , n ) ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Count 1 s present in a range of indices [ L , R ] in a given array | Function to find the size of the array if the array initially contains a single element ; Base case ; P \\/ 2 -> findSize ( N 2 ) P % 2 -> 1 P \\/ 2 -> findSize ( N \\/ 2 ) ; Function to return the count of 1 s in the range [ L , R ] ; Base Case ; PART 1 -> N \\/ 2 [ 1 , Siz_M ] ; Update the right end point of the range to min ( Siz_M , R ) ; PART 2 -> N % 2 [ SizM + 1 , Siz_M + 1 ] ; PART 3 -> N \\/ 2 [ SizM + 2 , 2 * Siz_M - 1 ] Same as PART 1 Property of Symmetricity Shift the coordinates according to PART 1 Subtract ( Siz_M + 1 ) from both L , R ; Driver Code ; Input ; Counts the number of 1 's in the range [L, R]\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def findSize ( N ) :\\n\\tif ( N == 0 ) :\\n\\t\\treturn 1\\n\\tif ( N == 1 ) :\\n\\t\\treturn 1\\n\\tSize = 2 * findSize ( N \\/\\/ 2 ) + 1\\n\\treturn Size\\ndef CountOnes ( N , L , R ) :\\n\\tif ( L > R ) :\\n\\t\\treturn 0\\n\\tif ( N <= 1 ) :\\n\\t\\treturn N\\n\\tret = 0\\n\\tM = N \\/\\/ 2\\n\\tSiz_M = findSize ( M )\\n\\tif ( L <= Siz_M ) :\\n\\t\\tret += CountOnes ( N \\/\\/ 2 , L , min ( Siz_M , R ) )\\n\\tif ( L <= Siz_M + 1 and Siz_M + 1 <= R ) :\\n\\t\\tret += N % 2\\n\\tif ( Siz_M + 1 < R ) :\\n\\t\\tret += CountOnes ( N \\/\\/ 2 , max ( 1 , L - Siz_M - 1 ) , R - Siz_M - 1 )\\n\\treturn ret\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tN = 7\\n\\tL = 2\\n\\tR = 5\\n\\tprint ( CountOnes ( N , L , R ) )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Count set bits in an integer | ; Check each bit in a number is set or not and return the total count of the set bits . ; ( 1 << i ) = pow ( 2 , i ) ; Driver Code\\\"\\nSolution in C:\",\"targets\":\"#include \\nint countSetBits ( int N ) { int count = 0 ; for ( int i = 0 ; i < sizeof ( int ) * 8 ; i ++ ) { if ( N & ( 1 << i ) ) count ++ ; } return count ; } int main ( ) { int N = 15 ; printf ( \\\" % d \\\" , countSetBits ( N ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Sort prime numbers of an array in descending order | C # implementation of the approach ; false here indicates that it is not prime ; If prime [ p ] is not changed , then it is a prime ; Update all multiples of p , set them to non - prime ; Function that sorts all the prime numbers from the array in descending ; this vector will contain prime numbers to sort ; if the element is prime ; update the array elements ; Driver code ; print the results .\\\"\\nSolution in C#:\",\"targets\":\"using System ; using System . Collections . Generic ; class GFG { static bool [ ] prime = new bool [ 100005 ] ; static void SieveOfEratosthenes ( int n ) { for ( int i = 0 ; i < 100005 ; i ++ ) prime [ i ] = true ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * 2 ; i < n ; i += p ) { prime [ i ] = false ; } } } } static void sortPrimes ( int [ ] arr , int n ) { SieveOfEratosthenes ( 100005 ) ; List < int > v = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( prime [ arr [ i ] ] ) { v . Add ( arr [ i ] ) ; } } v . Sort ( ) ; v . Reverse ( ) ; int j = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( prime [ arr [ i ] ] ) { arr [ i ] = v [ j ++ ] ; } } } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , 3 , 2 , 6 , 100 , 17 } ; int n = arr . Length ; sortPrimes ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( arr [ i ] + \\\" ▁ \\\" ) ; } } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"NFA to accept strings that has atleast one character occurring in a multiple of 3 | NFA variable that keeps track of the state while transaction . ; This checks for invalid input . ; Function for the state Q2 ; State transitions ' a ' takes to Q4 , and ' b ' and ' c ' remain at Q2 ; Function for the state Q3 ; State transitions ' a ' takes to Q3 , and ' b ' and ' c ' remain at Q4 ; Function for the state Q4 ; State transitions ' a ' takes to Q2 , and ' b ' and ' c ' remain at Q3 ; Function for the state Q5 ; State transitions ' b ' takes to Q6 , and ' a ' and ' c ' remain at Q5 ; Function for the state Q6 ; State transitions ' b ' takes to Q7 , and ' a ' and ' c ' remain at Q7 ; Function for the state Q7 ; State transitions ' b ' takes to Q5 , and ' a ' and ' c ' remain at Q7 ; Function for the state Q8 ; State transitions ' c ' takes to Q9 , and ' a ' and ' b ' remain at Q8 ; Function for the state Q9 ; State transitions ' c ' takes to Q10 , and ' a ' and ' b ' remain at Q9 ; Function for the state Q10 ; State transitions ' c ' takes to Q8 , and ' a ' and ' b ' remain at Q10 ; Function to check for 3 a 's ; Function to check for 3 b 's ; Function to check for 3 c 's ; Driver Code ; If any of the states is True , that is , if either the number of a ' s ▁ or ▁ number ▁ of ▁ b ' s or number of c 's is a multiple of three, then the is accepted\\\"\\nHow can the above be solved in Python?\",\"targets\":\"nfa = 1\\nflag = 0\\ndef state1 ( c ) :\\n\\tglobal nfa , flag\\n\\tif ( c == ' a ' ) :\\n\\t\\tnfa = 2\\n\\telif ( c == ' b ' or c == ' c ' ) :\\n\\t\\tnfa = 1\\n\\telse :\\n\\t\\tflag = 1\\ndef state2 ( c ) :\\n\\tglobal nfa , flag\\n\\tif ( c == ' a ' ) :\\n\\t\\tnfa = 3\\n\\telif ( c == ' b ' or c == ' c ' ) :\\n\\t\\tnfa = 2\\n\\telse :\\n\\t\\tflag = 1\\ndef state3 ( c ) :\\n\\tglobal nfa , flag\\n\\tif ( c == ' a ' ) :\\n\\t\\tnfa = 1\\n\\telif ( c == ' b ' or c == ' c ' ) :\\n\\t\\tnfa = 3\\n\\telse :\\n\\t\\tflag = 1\\ndef state4 ( c ) :\\n\\tglobal nfa , flag\\n\\tif ( c == ' b ' ) :\\n\\t\\tnfa = 5\\n\\telif ( c == ' a ' or c == ' c ' ) :\\n\\t\\tnfa = 4\\n\\telse :\\n\\t\\tflag = 1\\ndef state5 ( c ) :\\n\\tglobal nfa , flag\\n\\tif ( c == ' b ' ) :\\n\\t\\tnfa = 6\\n\\telif ( c == ' a ' or c == ' c ' ) :\\n\\t\\tnfa = 5\\n\\telse :\\n\\t\\tflag = 1\\ndef state6 ( c ) :\\n\\tglobal nfa , flag\\n\\tif ( c == ' b ' ) :\\n\\t\\tnfa = 4\\n\\telif ( c == ' a ' or c == ' c ' ) :\\n\\t\\tnfa = 6\\n\\telse :\\n\\t\\tflag = 1\\ndef state7 ( c ) :\\n\\tglobal nfa , flag\\n\\tif ( c == ' c ' ) :\\n\\t\\tnfa = 8\\n\\telif ( c == ' b ' or c == ' a ' ) :\\n\\t\\tnfa = 7\\n\\telse :\\n\\t\\tflag = 1\\ndef state8 ( c ) :\\n\\tglobal nfa , flag\\n\\tif ( c == ' c ' ) :\\n\\t\\tnfa = 9\\n\\telif ( c == ' b ' or c == ' a ' ) :\\n\\t\\tnfa = 8\\n\\telse :\\n\\t\\tflag = 1\\ndef state9 ( c ) :\\n\\tglobal nfa , flag\\n\\tif ( c == ' c ' ) :\\n\\t\\tnfa = 7\\n\\telif ( c == ' b ' or c == ' a ' ) :\\n\\t\\tnfa = 9\\n\\telse :\\n\\t\\tflag = 1\\ndef checkA ( s , x ) :\\n\\tglobal nfa , flag\\n\\tfor i in range ( x ) :\\n\\t\\tif ( nfa == 1 ) :\\n\\t\\t\\tstate1 ( s [ i ] )\\n\\t\\telif ( nfa == 2 ) :\\n\\t\\t\\tstate2 ( s [ i ] )\\n\\t\\telif ( nfa == 3 ) :\\n\\t\\t\\tstate3 ( s [ i ] )\\n\\tif ( nfa == 1 ) :\\n\\t\\treturn True\\n\\telse :\\n\\t\\tnfa = 4\\ndef checkB ( s , x ) :\\n\\tglobal nfa , flag\\n\\tfor i in range ( x ) :\\n\\t\\tif ( nfa == 4 ) :\\n\\t\\t\\tstate4 ( s [ i ] )\\n\\t\\telif ( nfa == 5 ) :\\n\\t\\t\\tstate5 ( s [ i ] )\\n\\t\\telif ( nfa == 6 ) :\\n\\t\\t\\tstate6 ( s [ i ] )\\n\\tif ( nfa == 4 ) :\\n\\t\\treturn True\\n\\telse :\\n\\t\\tnfa = 7\\ndef checkC ( s , x ) :\\n\\tglobal nfa , flag\\n\\tfor i in range ( x ) :\\n\\t\\tif ( nfa == 7 ) :\\n\\t\\t\\tstate7 ( s [ i ] )\\n\\t\\telif ( nfa == 8 ) :\\n\\t\\t\\tstate8 ( s [ i ] )\\n\\t\\telif ( nfa == 9 ) :\\n\\t\\t\\tstate9 ( s [ i ] )\\n\\tif ( nfa == 7 ) :\\n\\t\\treturn True\\ns = \\\" bbbca \\\"\\nx = 5\\nif ( checkA ( s , x ) or checkB ( s , x ) or checkC ( s , x ) )...\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Find a Fixed Point ( Value equal to index ) in a given array | C ++ program to check fixed point in an array using linear search ; If no fixed point present then return - 1 ; Driver code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int linearSearch ( int arr [ ] , int n ) { int i ; for ( i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == i ) return i ; } return -1 ; } int main ( ) { int arr [ ] = { -10 , -1 , 0 , 3 , 10 , 11 , 30 , 50 , 100 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; cout << \\\" Fixed ▁ Point ▁ is ▁ \\\" << linearSearch ( arr , n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Area of a Hexagon | C # program to find area of a Hexagon ; Create a function for calculating the area of the hexagon . ; Driver Code ; Length of a side\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { public static double hexagonArea ( double s ) { return ( ( 3 * Math . Sqrt ( 3 ) * ( s * s ) ) \\/ 2 ) ; } public static void Main ( ) { double s = 4 ; Console . WriteLine ( \\\" Area : ▁ \\\" + hexagonArea ( s ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Maximum element between two nodes of BST | C ++ program to find maximum element in the path between two Nodes of Binary Search Tree . ; Create and return a pointer of new Node . ; Insert a new Node in Binary Search Tree . ; Return the maximum element between a Node and its given ancestor . ; Traversing the path between ansector and Node and finding maximum element . ; Return maximum element in the path between two given Node of BST . ; Finding the LCA of Node x and Node y ; Checking if both the Node lie on the left side of the parent p . ; Checking if both the Node lie on the right side of the parent p . ; Return the maximum of maximum elements occur in path from ancestor to both Node . ; Driver Code ; Creating the root of Binary Search Tree ; Inserting Nodes in Binary Search Tree\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; struct Node { struct Node * left , * right ; int data ; } ; Node * createNode ( int x ) { Node * p = new Node ; p -> data = x ; p -> left = p -> right = NULL ; return p ; } void insertNode ( struct Node * root , int x ) { Node * p = root , * q = NULL ; while ( p != NULL ) { q = p ; if ( p -> data < x ) p = p -> right ; else p = p -> left ; } if ( q == NULL ) p = createNode ( x ) ; else { if ( q -> data < x ) q -> right = createNode ( x ) ; else q -> left = createNode ( x ) ; } } int maxelpath ( Node * q , int x ) { Node * p = q ; int mx = INT_MIN ; while ( p -> data != x ) { if ( p -> data > x ) { mx = max ( mx , p -> data ) ; p = p -> left ; } else { mx = max ( mx , p -> data ) ; p = p -> right ; } } return max ( mx , x ) ; } int maximumElement ( struct Node * root , int x , int y ) { Node * p = root ; while ( ( x < p -> data && y < p -> data ) || ( x > p -> data && y > p -> data ) ) { if ( x < p -> data && y < p -> data ) p = p -> left ; else if ( x > p -> data && y > p -> data ) p = p -> right ; } return max ( maxelpath ( p , x ) , maxelpath ( p , y ) ) ; } int main ( ) { int arr [ ] = { 18 , 36 , 9 , 6 , 12 , 10 , 1 , 8 } ; int a = 1 , b = 10 ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; struct Node * root = createNode ( arr [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) insertNode ( root , arr [ i ] ) ; cout << maximumElement ( root , a , b ) << endl ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Count Set | Recursive function to find number of set bist in a number ; Base condition ; If Least significant bit is set ; If Least significant bit is not set ; Driver code ; Function call\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def CountSetBits ( n ) :\\n\\tif ( n == 0 ) :\\n\\t\\treturn 0 ;\\n\\tif ( ( n & 1 ) == 1 ) :\\n\\t\\treturn 1 + CountSetBits ( n >> 1 ) ;\\n\\telse :\\n\\t\\treturn CountSetBits ( n >> 1 ) ;\\nif __name__ == ' _ _ main _ _ ' :\\n\\tn = 21 ;\\n\\tprint ( CountSetBits ( n ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"NFA to accept strings that has atleast one character occurring in a multiple of 3 | C # implementation of the above approach ; NFA variable that keeps track of the state while transaction . ; This checks for invalid input . ; Function for the state Q2 ; State transitions ' a ' takes to Q4 , and ' b ' and ' c ' remain at Q2 ; Function for the state Q3 ; State transitions ' a ' takes to Q3 , and ' b ' and ' c ' remain at Q4 ; Function for the state Q4 ; State transitions ' a ' takes to Q2 , and ' b ' and ' c ' remain at Q3 ; Function for the state Q5 ; State transitions ' b ' takes to Q6 , and ' a ' and ' c ' remain at Q5 ; Function for the state Q6 ; State transitions ' b ' takes to Q7 , and ' a ' and ' c ' remain at Q7 ; Function for the state Q7 ; State transitions ' b ' takes to Q5 , and ' a ' and ' c ' remain at Q7 ; Function for the state Q8 ; State transitions ' c ' takes to Q9 , and ' a ' and ' b ' remain at Q8 ; Function for the state Q9 ; State transitions ' c ' takes to Q10 , and ' a ' and ' b ' remain at Q9 ; Function for the state Q10 ; State transitions ' c ' takes to Q8 , and ' a ' and ' b ' remain at Q10 ; Function to check for 3 a 's ; Function to check for 3 b 's ; Function to check for 3 c 's ; Driver Code ; If any of the states is true , that is , if either the number of a ' s ▁ or ▁ number ▁ of ▁ b ' s or number of c 's is a multiple of three, then the string is accepted\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static int nfa = 1 ; static int flag = 0 ; static void state1 ( char c ) { if ( c == ' a ' ) nfa = 2 ; else if ( c == ' b ' c == ' c ' ) nfa = 1 ; else flag = 1 ; } static void state2 ( char c ) { if ( c == ' a ' ) nfa = 3 ; else if ( c == ' b ' c == ' c ' ) nfa = 2 ; else flag = 1 ; } static void state3 ( char c ) { if ( c == ' a ' ) nfa = 1 ; else if ( c == ' b ' c == ' c ' ) nfa = 3 ; else flag = 1 ; } static void state4 ( char c ) { if ( c == ' b ' ) nfa = 5 ; else if ( c == ' a ' c == ' c ' ) nfa = 4 ; else flag = 1 ; } static void state5 ( char c ) { if ( c == ' b ' ) nfa = 6 ; else if ( c == ' a ' c == ' c ' ) nfa = 5 ; else flag = 1 ; } static void state6 ( char c ) { if ( c == ' b ' ) nfa = 4 ; else if ( c == ' a ' c == ' c ' ) nfa = 6 ; else flag = 1 ; } static void state7 ( char c ) { if ( c == ' c ' ) nfa = 8 ; else if ( c == ' b ' c == ' a ' ) nfa = 7 ; else flag = 1 ; } static void state8 ( char c ) { if ( c == ' c ' ) nfa = 9 ; else if ( c == ' b ' c == ' a ' ) nfa = 8 ; else flag = 1 ; } static void state9 ( char c ) { if ( c == ' c ' ) nfa = 7 ; else if ( c == ' b ' c == ' a ' ) nfa = 9 ; else flag = 1 ; } static bool checkA ( String s , int x ) { for ( int i = 0 ; i < x ; i ++ ) { if ( nfa == 1 ) state1 ( s [ i ] ) ; else if ( nfa == 2 ) state2 ( s [ i ] ) ; else if ( nfa == 3 ) state3 ( s [ i ] ) ; } if ( nfa == 1 ) { return true ; } else { nfa = 4 ; } return false ; } static bool checkB ( String s , int x ) { for ( int i = 0 ; i < x ; i ++ ) { if ( nfa == 4 ) state4 ( s [ i ] ) ; else if ( nfa == 5 ) state5 ( s [ i ] ) ; else if ( nfa == 6 ) state6 ( s [ i ] ) ; } if ( nfa == 4 ) { return true ; } else { nfa = 7 ; } return false ; } static bool checkC ( String s , int x ) { for ( int i = 0 ; i < x ; i ++ ) { if ( nfa == 7 ) state7 ( s [ i ] ) ; else if ( nfa == 8 ) state8 ( s [ i ] ) ; else if ( nfa == 9 ) state9 ( s [ i ] ) ; } if ( nfa == 7 ) { return true ; } return false ; } public static void Main ( String [ ] args ) { String s = \\\" bbbca \\\" ; int x = 5 ; if (...\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Length of longest palindrome list in a linked list using O ( 1 ) extra space | C # program to find longest palindrome sublist in a list in O ( 1 ) time . ; structure of the linked list ; function for counting the common elements ; loop to count coomon in the list starting from node a and b ; increment the count for same values ; Returns length of the longest palindrome sublist in given list ; loop till the end of the linked list ; The sublist from head to current reversed . ; check for odd length palindrome by finding longest common list elements beginning from prev and from next ( We exclude curr ) ; check for even length palindrome by finding longest common list elements beginning from curr and from next ; update prev and curr for next iteration ; Utility function to create a new list node ; Driver code ; Let us create a linked lists to test the functions Created list is a : 2 -> 4 -> 3 -> 4 -> 2 -> 15\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GfG { public class Node { public int data ; public Node next ; } static int countCommon ( Node a , Node b ) { int count = 0 ; for ( ; a != null && b != null ; a = a . next , b = b . next ) if ( a . data == b . data ) ++ count ; else break ; return count ; } static int maxPalindrome ( Node head ) { int result = 0 ; Node prev = null , curr = head ; while ( curr != null ) { Node next = curr . next ; curr . next = prev ; result = Math . Max ( result , 2 * countCommon ( prev , next ) + 1 ) ; result = Math . Max ( result , 2 * countCommon ( curr , next ) ) ; prev = curr ; curr = next ; } return result ; } static Node newNode ( int key ) { Node temp = new Node ( ) ; temp . data = key ; temp . next = null ; return temp ; } public static void Main ( String [ ] args ) { Node head = newNode ( 2 ) ; head . next = newNode ( 4 ) ; head . next . next = newNode ( 3 ) ; head . next . next . next = newNode ( 4 ) ; head . next . next . next . next = newNode ( 2 ) ; head . next . next . next . next . next = newNode ( 15 ) ; Console . WriteLine ( maxPalindrome ( head ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Find the smallest and second smallest elements in an array | Function to print first smallest and second smallest elements ; There should be atleast two elements ; If current element is smaller than first then update both first and second ; If arr [ i ] is in between first and second then update second ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function print2Smallest ( $ arr , $ arr_size ) { $ INT_MAX = 2147483647 ; if ( $ arr_size < 2 ) { echo ( \\\" ▁ Invalid ▁ Input ▁ \\\" ) ; return ; } $ first = $ second = $ INT_MAX ; for ( $ i = 0 ; $ i < $ arr_size ; $ i ++ ) { if ( $ arr [ $ i ] < $ first ) { $ second = $ first ; $ first = $ arr [ $ i ] ; } else if ( $ arr [ $ i ] < $ second && $ arr [ $ i ] != $ first ) $ second = $ arr [ $ i ] ; } if ( $ second == $ INT_MAX ) echo ( \\\" There ▁ is ▁ no ▁ second ▁ smallest ▁ element \\n \\\" ) ; else echo \\\" The ▁ smallest ▁ element ▁ is ▁ \\\" , $ first , \\\" ▁ and ▁ second ▁ Smallest ▁ element ▁ is ▁ \\\" , $ second ; } $ arr = array ( 12 , 13 , 1 , 10 , 34 , 1 ) ; $ n = count ( $ arr ) ; print2Smallest ( $ arr , $ n ) ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Print squares of first n natural numbers without using * , \\/ and | Javascript program to print squares of first ' n ' natural numbers wothout using * , \\/ and - ; Initialize ' square ' and first odd number ; Calculate and print squares ; Print square ; Update ' square ' and ' odd ' ; Driver program to test above function\\\"\\nSolution in Javascript:\",\"targets\":\"function printSquares ( n ) { let square = 0 , odd = 1 ; for ( let x = 0 ; x < n ; x ++ ) { document . write ( square + \\\" \\\" ) ; square = square + odd ; odd = odd + 2 ; } } let n = 5 ; printSquares ( n ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Probability of distributing given balls into two halves having equal count of distinct colors | Stores the count of distinct colors in box1 ; Stores the count of distinct colors in box2 ; Function to calculate the required probability ; Calculate factorial from [ 1 , 10 ] ; Assign all distinct balls to second box ; Total number of balls ; Calculate total number of balls ; If K is an odd number ; Total ways of distributing the balls in two equal halves ; Required number of ways ; Return the required probability ; Function to calculate total number of possible distributions which satisfies the given conditions ; If used balls is equal to K \\/ 2 ; If box1 is equal to box2 ; Base condition ; Stores the number of ways of distributing remaining balls without including the current balls in box1 ; Increment box1 by one ; Iterate over the range [ 1 , balls [ i ] ] ; If all the balls goes to box1 , then decrease box2 by one ; Total number of ways of selecting j balls ; Increment res by total number of valid ways of distributing the remaining balls ; Decrement box1 by one ; Increment box2 by 1 ; Function to calculate factorial of N ; Base Case ; Iterate over the range [ 1 , N ] ; Function to calculate NcR ; Driver Code ; Print the result\\\"\\nSolution in Python:\",\"targets\":\"box1 = 0\\nbox2 = 0\\nfact = [ 0 for i in range ( 11 ) ]\\ndef getProbability ( balls ) :\\n\\tglobal box1 , box2 , fact\\n\\tfactorial ( 10 )\\n\\tbox2 = len ( balls )\\n\\tK = 0\\n\\tfor i in range ( len ( balls ) ) :\\n\\t\\tK += balls [ i ]\\n\\tif ( K % 2 == 1 ) :\\n\\t\\treturn 0\\n\\tall = comb ( K , K \\/\\/ 2 )\\n\\tvalidPermutation = validPermutations ( K \\/\\/ 2 , balls , 0 , 0 )\\n\\treturn validPermutation \\/ all\\ndef validPermutations ( n , balls , usedBalls , i ) :\\n\\tglobal box1 , box2 , fact\\n\\tif ( usedBalls == n ) :\\n\\t\\tif ( box1 == box2 ) :\\n\\t\\t\\treturn 1\\n\\t\\telse :\\n\\t\\t\\treturn 0\\n\\tif ( i >= len ( balls ) ) :\\n\\t\\treturn 0\\n\\tres = validPermutations ( n , balls , usedBalls , i + 1 )\\n\\tbox1 += 1\\n\\tfor j in range ( 1 , balls [ i ] + 1 ) :\\n\\t\\tif ( j == balls [ i ] ) :\\n\\t\\t\\tbox2 -= 1\\n\\t\\tcombinations = comb ( balls [ i ] , j )\\n\\t\\tres += combinations * validPermutations ( n , balls , usedBalls + j , i + 1 )\\n\\tbox1 -= 1\\n\\tbox2 += 1\\n\\treturn res\\ndef factorial ( N ) :\\n\\tglobal box1 , box2 , fact\\n\\tfact [ 0 ] = 1\\n\\tfor i in range ( 1 , N + 1 ) :\\n\\t\\tfact [ i ] = fact [ i - 1 ] * i\\ndef comb ( n , r ) :\\n\\tglobal box1 , box2 , fact\\n\\tres = fact [ n ] \\/\\/ fact [ r ]\\n\\tres \\/\\/= fact [ n - r ]\\n\\treturn res\\narr = [ 2 , 1 , 1 ]\\nN = 4\\nprint ( getProbability ( arr ) )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"Sum of the multiples of two numbers below N | C program for above approach ; Function to return the sum of all the integers below N which are multiples of either A or B ; If i is a multiple of a or b ; Driver Code\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint findSum ( int n , int a , int b ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( i % a == 0 i % b == 0 ) sum += i ; return sum ; } int main ( ) { int n = 10 , a = 3 , b = 5 ; printf ( \\\" % d \\\" , findSum ( n , a , b ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"One line function for factorial of a number | Javascript program to find factorial of given number ; single line to find factorial ; Driver Code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function factorial ( n ) { return ( n == 1 n == 0 ) ? 1 : n * factorial ( n - 1 ) ; } let num = 5 ; document . write ( \\\" \\\" , num , \\\" \\\" , factorial ( num ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Print n smallest elements from given array in their original order | Function for binary_search ; Function to print smallest n numbers ; Make copy of array ; Sort copy array ; For each arr [ i ] find whether it is a part of n - smallest with binary search ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"def binary_search ( arr , low , high , ele ) :\\n\\twhile low < high :\\n\\t\\tmid = ( low + high ) \\/\\/ 2\\n\\t\\tif arr [ mid ] == ele :\\n\\t\\t\\treturn mid\\n\\t\\telif arr [ mid ] > ele :\\n\\t\\t\\thigh = mid\\n\\t\\telse :\\n\\t\\t\\tlow = mid + 1\\n\\treturn - 1\\ndef printSmall ( arr , asize , n ) :\\n\\tcopy_arr = arr . copy ( )\\n\\tcopy_arr . sort ( )\\n\\tfor i in range ( asize ) :\\n\\t\\tif binary_search ( copy_arr , low = 0 , high = n , ele = arr [ i ] ) > - 1 :\\n\\t\\t\\tprint ( arr [ i ] , end = \\\" ▁ \\\" )\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tarr = [ 1 , 5 , 8 , 9 , 6 , 7 , 3 , 4 , 2 , 0 ]\\n\\tasize = len ( arr )\\n\\tn = 5\\n\\tprintSmall ( arr , asize , n )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Ternary Search | C ++ program to illustrate recursive approach to ternary search ; Function to perform Ternary Search ; Find the mid1 and mid2 ; Check if key is present at any mid ; Since key is not present at mid , check in which region it is present then repeat the Search operation in that region ; The key lies in between l and mid1 ; The key lies in between mid2 and r ; The key lies in between mid1 and mid2 ; Key not found ; Driver code ; Get the array Sort the array if not sorted ; Starting index ; length of array ; Key to be searched in the array ; Search the key using ternarySearch ; Print the result ; Key to be searched in the array ; Search the key using ternarySearch ; Print the result\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int ternarySearch ( int l , int r , int key , int ar [ ] ) { if ( r >= l ) { int mid1 = l + ( r - l ) \\/ 3 ; int mid2 = r - ( r - l ) \\/ 3 ; if ( ar [ mid1 ] == key ) { return mid1 ; } if ( ar [ mid2 ] == key ) { return mid2 ; } if ( key < ar [ mid1 ] ) { return ternarySearch ( l , mid1 - 1 , key , ar ) ; } else if ( key > ar [ mid2 ] ) { return ternarySearch ( mid2 + 1 , r , key , ar ) ; } else { return ternarySearch ( mid1 + 1 , mid2 - 1 , key , ar ) ; } } return -1 ; } int main ( ) { int l , r , p , key ; int ar [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 } ; l = 0 ; r = 9 ; key = 5 ; p = ternarySearch ( l , r , key , ar ) ; cout << \\\" Index ▁ of ▁ \\\" << key << \\\" ▁ is ▁ \\\" << p << endl ; key = 50 ; p = ternarySearch ( l , r , key , ar ) ; cout << \\\" Index ▁ of ▁ \\\" << key << \\\" ▁ is ▁ \\\" << p << endl ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Sentence Case of a given Camel cased string | C ++ implementation of the approach ; Function to return the original string after converting it back from camelCase ; Print the first character as it is ; Traverse the rest of the characters one by one ; If current character is uppercase print space followed by the current character in lowercase ; Else print the current character ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; void getOrgString ( string s ) { cout << s [ 0 ] ; int i = 1 ; while ( i < s . length ( ) ) { if ( s [ i ] >= ' A ' && s [ i ] <= ' Z ' ) cout << \\\" ▁ \\\" << ( char ) tolower ( s [ i ] ) ; else cout << s [ i ] ; i ++ ; } } int main ( ) { string s = \\\" ILoveGeeksForGeeks \\\" ; getOrgString ( s ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Union and Intersection of two sorted arrays | Function prints union of arr1 [ ] and arr2 [ ] m is the number of elements in arr1 [ ] n is the number of elements in arr2 [ ] ; Print remaining elements of the larger array ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function printUnion ( $ arr1 , $ arr2 , $ m , $ n ) { $ i = 0 ; $ j = 0 ; while ( $ i < $ m && $ j < $ n ) { if ( $ arr1 [ $ i ] < $ arr2 [ $ j ] ) echo ( $ arr1 [ $ i ++ ] . \\\" ▁ \\\" ) ; else if ( $ arr2 [ $ j ] < $ arr1 [ $ i ] ) echo ( $ arr2 [ $ j ++ ] . \\\" ▁ \\\" ) ; else { echo ( $ arr2 [ $ j ++ ] . \\\" \\\" ) ; $ i ++ ; } } while ( $ i < $ m ) echo ( $ arr1 [ $ i ++ ] . \\\" ▁ \\\" ) ; while ( $ j < $ n ) echo ( $ arr2 [ $ j ++ ] . \\\" ▁ \\\" ) ; } $ arr1 = array ( 1 , 2 , 4 , 5 , 6 ) ; $ arr2 = array ( 2 , 3 , 5 , 7 ) ; $ m = sizeof ( $ arr1 ) ; $ n = sizeof ( $ arr2 ) ; printUnion ( $ arr1 , $ arr2 , $ m , $ n ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Check if lowercase and uppercase characters are in same order | Function to check if both the case follow the same order ; Traverse the string ; Store both lowercase and uppercase in two different strings ; transfor lowerStr to uppercase ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"def isCheck ( str ) :\\n\\tlength = len ( str )\\n\\tlowerStr , upperStr = \\\" \\\" , \\\" \\\"\\n\\tfor i in range ( length ) :\\n\\t\\tif ( ord ( str [ i ] ) >= 65 and ord ( str [ i ] ) <= 91 ) :\\n\\t\\t\\tupperStr = upperStr + str [ i ]\\n\\t\\telse :\\n\\t\\t\\tlowerStr = lowerStr + str [ i ]\\n\\ttransformStr = lowerStr . upper ( )\\n\\treturn transformStr == upperStr\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tstr = \\\" geeGkEEsKS \\\"\\n\\tif isCheck ( str ) :\\n\\t\\tprint ( \\\" Yes \\\" )\\n\\telse :\\n\\t\\tprint ( \\\" No \\\" )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"XOR of two numbers after making length of their binary representations equal | function to count the number of bits in binary representation of an integer ; initialize count ; count till n is non zero ; right shift by 1 i . e , divide by 2 ; function to calculate the xor of two numbers by adding trailing zeros to the number having less number of bits in its binary representation . ; stores the minimum and maximum ; left shift if the number of bits are less in binary representation ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function count1 ( $ n ) { $ c = 0 ; while ( $ n ) { $ c ++ ; $ n = $ n >> 1 ; } return $ c ; } function XOR1 ( $ a , $ b ) { $ c = min ( $ a , $ b ) ; $ d = max ( $ a , $ b ) ; if ( count1 ( $ c ) < count1 ( $ d ) ) $ c = $ c << ( count1 ( $ d ) - count1 ( $ c ) ) ; return ( $ c ^ $ d ) ; } $ a = 13 ; $ b = 5 ; echo XOR1 ( $ a , $ b ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Program to find the head start in a race | Function to find the B start to C ; When B completed it 's 100 meter then Completed meters by C is ; Driver Code ; When A completed it 's 100 meter Then completed meters of B and C is\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function Race ( B , C ) { var result = 0 ; result = ( ( C * 100 ) \\/ B ) ; return 100 - result ; } var B = 10 , C = 28 ; B = 100 - B ; C = 100 - C ; document . write ( Race ( B , C ) + \\\" \\\" ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"Union and Intersection of two sorted arrays | C program to find union of two sorted arrays ; Function prints union of arr1 [ ] and arr2 [ ] m is the number of elements in arr1 [ ] n is the number of elements in arr2 [ ] ; Print remaining elements of the larger array ; Driver program to test above function\\nHow can the above be solved in C?\",\"targets\":\"#include \\nvoid printUnion ( int arr1 [ ] , int arr2 [ ] , int m , int n ) { int i = 0 , j = 0 ; while ( i < m && j < n ) { if ( arr1 [ i ] < arr2 [ j ] ) printf ( \\\" ▁ % d ▁ \\\" , arr1 [ i ++ ] ) ; else if ( arr2 [ j ] < arr1 [ i ] ) printf ( \\\" ▁ % d ▁ \\\" , arr2 [ j ++ ] ) ; else { printf ( \\\" ▁ % d ▁ \\\" , arr2 [ j ++ ] ) ; i ++ ; } } while ( i < m ) printf ( \\\" ▁ % d ▁ \\\" , arr1 [ i ++ ] ) ; while ( j < n ) printf ( \\\" ▁ % d ▁ \\\" , arr2 [ j ++ ] ) ; } int main ( ) { int arr1 [ ] = { 1 , 2 , 4 , 5 , 6 } ; int arr2 [ ] = { 2 , 3 , 5 , 7 } ; int m = sizeof ( arr1 ) \\/ sizeof ( arr1 [ 0 ] ) ; int n = sizeof ( arr2 ) \\/ sizeof ( arr2 [ 0 ] ) ; printUnion ( arr1 , arr2 , m , n ) ; getchar ( ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Largest palindromic number in an array | C # implementation of above approach ; Function to check if n is palindrome ; Find the appropriate divisor to extract the leading digit ; If first and last digits are not same then return false ; Removing the leading and trailing digits from the number ; Reducing divisor by a factor of 2 as 2 digits are dropped ; Function to find the largest palindromic number ; If a palindrome larger than the currentMax is found ; Return the largest palindromic number from the array ; Driver program ; print required answer\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static bool isPalindrome ( int n ) { int divisor = 1 ; while ( n \\/ divisor >= 10 ) divisor *= 10 ; while ( n != 0 ) { int leading = n \\/ divisor ; int trailing = n % 10 ; if ( leading != trailing ) return false ; n = ( n % divisor ) \\/ 10 ; divisor = divisor \\/ 100 ; } return true ; } static int largestPalindrome ( int [ ] A , int n ) { int currentMax = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( A [ i ] > currentMax && isPalindrome ( A [ i ] ) ) currentMax = A [ i ] ; } return currentMax ; } public static void Main ( ) { int [ ] A = { 1 , 232 , 54545 , 999991 } ; int n = A . Length ; Console . WriteLine ( largestPalindrome ( A , n ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Undulating numbers | C # program to check whether a number is undulating or not ; Considering the definition with restriction that there should be at least 3 digits ; Check if all alternate digits are same or not . ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { public static bool isUndulating ( string n ) { if ( n . Length <= 2 ) return false ; for ( int i = 2 ; i < n . Length ; i ++ ) if ( n [ i - 2 ] != n [ i ] ) return false ; return true ; } public static void Main ( ) { string n = \\\"1212121\\\" ; if ( isUndulating ( n ) == true ) Console . WriteLine ( \\\" yes \\\" ) ; else Console . WriteLine ( \\\" no \\\" ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Fibonacci problem ( Value of Fib ( N ) * Fib ( N ) | PHP implementation of the approach ; Driver code\\\"\\nSolution in php:\",\"targets\":\"< ? php function getResult ( $ n ) { if ( $ n & 1 ) return 1 ; return -1 ; } $ n = 3 ; echo getResult ( $ n ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Print all possible combinations of r elements in a given array of size n | Program to print all combination of size r in an array of size n ; The main function that prints all combinations of size r in arr [ ] of size n . This function mainly uses combinationUtil ( ) ; A temporary array to store all combination one by one ; Print all combination using temprary array ' data [ ] ' ; arr [ ] -- -> Input Array n -- -> Size of input array r -- -> Size of a combination to be printed index -- -> Current index in data [ ] data [ ] -- -> Temporary array to store current combination i -- -> index of current element in arr [ ] ; Current cobination is ready , print it ; When no more elements are there to put in data [ ] ; current is included , put next at next location ; current is excluded , replace it with next ( Note that i + 1 is passed , but index is not changed ) ; Driver program to test above functions\\\"\\nSolution in C:\",\"targets\":\"#include \\nvoid combinationUtil ( int arr [ ] , int n , int r , int index , int data [ ] , int i ) ; void printCombination ( int arr [ ] , int n , int r ) { int data [ r ] ; combinationUtil ( arr , n , r , 0 , data , 0 ) ; } void combinationUtil ( int arr [ ] , int n , int r , int index , int data [ ] , int i ) { if ( index == r ) { for ( int j = 0 ; j < r ; j ++ ) printf ( \\\" % d ▁ \\\" , data [ j ] ) ; printf ( \\\" \\n \\\" ) ; return ; } if ( i >= n ) return ; data [ index ] = arr [ i ] ; combinationUtil ( arr , n , r , index + 1 , data , i + 1 ) ; combinationUtil ( arr , n , r , index , data , i + 1 ) ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int r = 3 ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; printCombination ( arr , n , r ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Rearrange array to maximize sum of GCD of array elements with their respective indices | C ++ program to implement the above approach ; Function to find the maximum sum of GCD ( arr [ i ] , i ) by rearranging the array ; Stores maximum sum of GCD ( arr [ i ] , i ) by rearranging the array elements ; Update res ; Driver Code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int findMaxValByRearrArr ( int arr [ ] , int N ) { int res = 0 ; res = ( N * ( N + 1 ) ) \\/ 2 ; return res ; } int main ( ) { int arr [ ] = { 3 , 2 , 1 } ; int N = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; cout << findMaxValByRearrArr ( arr , N ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Find Cube Pairs | Set 1 ( A n ^ ( 2 \\/ 3 ) Solution ) | C # program to find pairs that can represent the given number as sum of two cubes ; Function to find pairs that can represent the given number as sum of two cubes ; find cube root of n ; create an empty map ; Consider all pairs such with values less than cuberoot ; find sum of current pair ( x , y ) ; do nothing if sum is not equal to given number ; if sum is seen before , we found two pairs ; if sum is seen for the first time ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; using System . Collections . Generic ; class GFG { class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void findPairs ( int n ) { int cubeRoot = ( int ) Math . Pow ( n , 1.0 \\/ 3.0 ) ; Dictionary < int , pair > s = new Dictionary < int , pair > ( ) ; for ( int x = 1 ; x < cubeRoot ; x ++ ) { for ( int y = x + 1 ; y <= cubeRoot ; y ++ ) { int sum = x * x * x + y * y * y ; if ( sum != n ) continue ; if ( s . ContainsKey ( sum ) ) { Console . Write ( \\\" ( \\\" + s [ sum ] . first + \\\" , ▁ \\\" + s [ sum ] . second + \\\" ) ▁ and ▁ ( \\\" + x + \\\" , ▁ \\\" + y + \\\" ) \\\" + \\\" \\n \\\" ) ; } else s . Add ( sum , new pair ( x , y ) ) ; } } } public static void Main ( String [ ] args ) { int n = 13832 ; findPairs ( n ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Queries to count points lying on or inside an isosceles Triangle with given length of equal sides | Python3 implementation of above approach ; Function to find answer of each query ; Stores the count of points with sum less than or equal to their indices ; Traverse the array ; ` If both x and y - coordinate < 0 ; Stores the sum of co - ordinates ; Increment count of sum by 1 ; Prefix array ; Perform queries ; Drivers Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"MAX = 10 ** 6 + 5\\nfrom math import ceil\\ndef query ( arr , Q ) :\\n\\tpre = [ 0 ] * ( MAX )\\n\\tfor i in range ( len ( arr ) ) :\\n\\t\\tif ( arr [ i ] [ 0 ] < 0 or arr [ i ] [ 1 ] < 0 ) :\\n\\t\\t\\tcontinue\\n\\t\\tsum = ceil ( ( arr [ i ] [ 0 ] + arr [ i ] [ 1 ] ) ) ;\\n\\t\\tpre [ sum ] += 1\\n\\tfor i in range ( 1 , MAX ) :\\n\\t\\tpre [ i ] += pre [ i - 1 ]\\n\\tfor i in range ( len ( Q ) ) :\\n\\t\\tprint ( pre [ Q [ i ] ] , end = \\\" ▁ \\\" )\\nif __name__ == ' _ _ main _ _ ' :\\n\\tarr = [ [ 2.1 , 3.0 ] , [ 3.7 , 1.2 ] , [ 1.5 , 6.5 ] , [ 1.2 , 0.0 ] ]\\n\\tQ = [ 2 , 8 , 5 ]\\n\\tN = len ( arr )\\n\\tM = len ( Q )\\n\\tquery ( arr , Q )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Area of Equilateral triangle inscribed in a Circle of radius R | Function to find the area of equilateral triangle inscribed in a circle of radius R ; Base and Height of equilateral triangle ; Area using Base and Height ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"def area ( R ) :\\n\\tbase = 1.732 * R\\n\\theight = ( 3 \\/ 2 ) * R\\n\\tarea = ( ( 1 \\/ 2 ) * base * height )\\n\\treturn area\\nif __name__ == ' _ _ main _ _ ' :\\n\\tR = 7\\n\\tprint ( area ( R ) )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Find the Alpha Score of the Given Steps ( Using BST ) | C # program to implement the above approach ; Structure of a node ; Function to calculate and return the Alpha Score of the journey ; Traverse left subtree ; Calculate the alpha score of the current step ; Update alpha score of the journey ; Traverse right subtree ; Return ; Function to construct a BST from the sorted array [ ] arr ; Insert root ; Construct left subtree ; Construct right subtree ; Return root ; Driver Code ; Sort the array ; Construct BST from the sorted array\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class Node { public Node left , right ; public int data ; public Node ( int data ) { this . data = data ; left = null ; right = null ; } } class AlphaScore { Node root ; AlphaScore ( ) { root = null ; } static long sum = 0 , total_sum = 0 ; static long mod = 1000000007 ; static long getAlphaScore ( Node node ) { if ( node . left != null ) getAlphaScore ( node . left ) ; sum = ( sum + node . data ) % mod ; total_sum = ( total_sum + sum ) % mod ; if ( node . right != null ) getAlphaScore ( node . right ) ; return total_sum ; } static Node constructBST ( int [ ] arr , int start , int end , Node root ) { if ( start > end ) return null ; int mid = ( start + end ) \\/ 2 ; if ( root == null ) root = new Node ( arr [ mid ] ) ; root . left = constructBST ( arr , start , mid - 1 , root . left ) ; root . right = constructBST ( arr , mid + 1 , end , root . right ) ; return root ; } public static void Main ( String [ ] args ) { int [ ] arr = { 10 , 11 , 12 } ; int length = arr . Length ; Array . Sort ( arr ) ; Node root = null ; root = constructBST ( arr , 0 , length - 1 , root ) ; Console . WriteLine ( getAlphaScore ( root ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Maximum sum path in a matrix from top to bottom | C ++ implementation to find the maximum sum path in a matrix ; function to find the maximum sum path in a matric ; if there is a single element only ; dp [ ] [ ] matrix to store the results of each iteration ; base case , copying elements of last row ; building up the dp [ ] [ ] matrix from bottom to the top row ; finding the maximum diagonal element in the ( i + 1 ) th row if that cell exists ; adding that ' max ' element to the mat [ i ] [ j ] element ; finding the maximum value from the first row of dp [ ] [ ] ; required maximum sum ; Driver program to test above\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; #define SIZE 10\\nint maxSum ( int mat [ SIZE ] [ SIZE ] , int n ) { if ( n == 1 ) return mat [ 0 ] [ 0 ] ; int dp [ n ] [ n ] ; int maxSum = INT_MIN , max ; for ( int j = 0 ; j < n ; j ++ ) dp [ n - 1 ] [ j ] = mat [ n - 1 ] [ j ] ; for ( int i = n - 2 ; i >= 0 ; i -- ) { for ( int j = 0 ; j < n ; j ++ ) { max = INT_MIN ; if ( ( ( j - 1 ) >= 0 ) && ( max < dp [ i + 1 ] [ j - 1 ] ) ) max = dp [ i + 1 ] [ j - 1 ] ; if ( ( ( j + 1 ) < n ) && ( max < dp [ i + 1 ] [ j + 1 ] ) ) max = dp [ i + 1 ] [ j + 1 ] ; dp [ i ] [ j ] = mat [ i ] [ j ] + max ; } } for ( int j = 0 ; j < n ; j ++ ) if ( maxSum < dp [ 0 ] [ j ] ) maxSum = dp [ 0 ] [ j ] ; return maxSum ; } int main ( ) { int mat [ SIZE ] [ SIZE ] = { { 5 , 6 , 1 , 7 } , { -2 , 10 , 8 , -1 } , { 3 , -7 , -9 , 11 } , { 12 , -4 , 2 , 6 } } ; int n = 4 ; cout << \\\" Maximum ▁ Sum ▁ = ▁ \\\" << maxSum ( mat , n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Remove even frequency characters from the string | Function that removes the characters which have even frequencies in the string ; create a map to store the frequency of each character ; to store the new string ; remove the characters which have even frequencies ; if the character has even frequency then skip ; else concatenate the character to the new string ; display the modified string ; Driver code ; remove the characters which have even frequencies\\\"\\nSolution in Python:\",\"targets\":\"def solve ( s ) :\\n\\tm = dict ( )\\n\\tfor i in range ( len ( s ) ) :\\n\\t\\tif s [ i ] in m :\\n\\t\\t\\tm [ s [ i ] ] = m [ s [ i ] ] + 1\\n\\t\\telse :\\n\\t\\t\\tm [ s [ i ] ] = 1\\n\\tnew_string = \\\" \\\"\\n\\tfor i in range ( len ( s ) ) :\\n\\t\\tif m [ s [ i ] ] % 2 == 0 :\\n\\t\\t\\tcontinue\\n\\t\\tnew_string = new_string + s [ i ]\\n\\tprint ( new_string )\\nif __name__ == ' _ _ main _ _ ' :\\n\\ts = \\\" aabbbddeeecc \\\"\\n\\tsolve ( s )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Find next greater element with no consecutive 1 in it 's binary representation | C ++ implementation of the approach ; To store the pre - computed integers ; Function that returns true if the binary representation of x contains consecutive 1 s ; To store the previous bit ; Check whether the previous bit and the current bit are both 1 ; Update previous bit ; Go to the next bit ; Function to pre - compute the valid numbers from 0 to MAX ; Store all the numbers which do not have consecutive 1 s ; Function to return the minimum number greater than n which does not contain consecutive 1 s ; Search for the next greater element with no consecutive 1 s ; Function to perform the queries ; Driver code ; Pre - compute the numbers ; Perform the queries\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; const int MAX = 100000 ; vector < int > v ; int consecutiveOnes ( int x ) { int p = 0 ; while ( x > 0 ) { if ( x % 2 == 1 and p == 1 ) return true ; p = x % 2 ; x \\/= 2 ; } return false ; } void preCompute ( ) { for ( int i = 0 ; i <= MAX ; i ++ ) { if ( ! consecutiveOnes ( i ) ) v . push_back ( i ) ; } } int nextValid ( int n ) { int it = upper_bound ( v . begin ( ) , v . end ( ) , n ) - v . begin ( ) ; int val = v [ it ] ; return val ; } void performQueries ( int queries [ ] , int q ) { for ( int i = 0 ; i < q ; i ++ ) cout << nextValid ( queries [ i ] ) << \\\" \\n \\\" ; } int main ( ) { int queries [ ] = { 4 , 6 } ; int q = sizeof ( queries ) \\/ sizeof ( int ) ; preCompute ( ) ; performQueries ( queries , q ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Maximum number of pair reductions possible on a given triplet | C ++ program for the above approach ; Function to count the maximum number of pair reductions possible on a given triplet ; Convert them into an array ; Stores count of operations ; Sort the array ; If the first two array elements reduce to 0 ; Apply the operations ; Increment count ; Print the maximum count ; Driver Code ; Given triplet\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; void maxOps ( int a , int b , int c ) { int arr [ ] = { a , b , c } ; int count = 0 ; while ( 1 ) { sort ( arr , arr + 3 ) ; if ( ! arr [ 0 ] && ! arr [ 1 ] ) break ; arr [ 1 ] -= 1 ; arr [ 2 ] -= 1 ; count += 1 ; } cout << count ; } int main ( ) { int a = 4 , b = 3 , c = 2 ; maxOps ( a , b , c ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Count ways to construct array with even product from given array such that absolute difference of same indexed elements is at most 1 | Function to find count the ways to construct an array , B such that abs ( A [ i ] - B [ i ] ) <= 1 and product of elements of B is even ; Stores count of arrays B such that abs ( A [ i ] - B [ i ] ) <= 1 ; Stores count of arrays B whose product of elements is not even ; Traverse the array ; Update total ; If A [ i ] is an even number ; Update oddArray ; Print var 3 ^ N - 2 ^ X ; Driver Code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function cntWaysConsArray ( A , N ) { var total = 1 ; var oddArray = 1 ; for ( i = 0 ; i < N ; i ++ ) { total = total * 3 ; if ( A [ i ] % 2 == 0 ) { oddArray *= 2 ; } } document . write ( total - oddArray ) ; } var A = [ 2 , 4 ] ; var N = A . length ; cntWaysConsArray ( A , N ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Find the n | function to find nth number made of even digits only ; If n = 1 return 0 ; vector to store the digits when converted into base 5 ; Reduce n to n - 1 to exclude 0 ; Reduce n to base 5 number and store digits ; pushing the digits into vector ; variable to represent the number after converting it to base 5. Since the digits are be in reverse order , we traverse vector from back ; return 2 * result ( to convert digits 0 , 1 , 2 , 3 , 4 to 0 , 2 , 4 , 6 , 8. ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function findNthEvenDigitNumber ( $ n ) { if ( $ n == 1 ) return 0 ; $ v = array ( ) ; $ n = $ n - 1 ; while ( $ n > 0 ) { array_push ( $ v , $ n % 5 ) ; $ n = ( int ) ( $ n \\/ 5 ) ; } $ result = 0 ; for ( $ i = count ( $ v ) - 1 ; $ i >= 0 ; $ i -- ) { $ result = $ result * 10 ; $ result = $ result + $ v [ $ i ] ; } return 2 * $ result ; } echo findNthEvenDigitNumber ( 2 ) . \\\" \\n \\\" ; echo findNthEvenDigitNumber ( 10 ) . \\\" \\n \\\" ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"Find a pair with the given difference | C program to find a pair with the given difference ; The function assumes that the array is sorted ; Initialize positions of two elements ; Search for a pair ; Driver program to test above function\\nHow can the above be solved in C?\",\"targets\":\"#include \\nbool findPair ( int arr [ ] , int size , int n ) { int i = 0 ; int j = 1 ; while ( i < size && j < size ) { if ( i != j && arr [ j ] - arr [ i ] == n ) { printf ( \\\" Pair ▁ Found : ▁ ( % d , ▁ % d ) \\\" , arr [ i ] , arr [ j ] ) ; return true ; } else if ( arr [ j ] - arr [ i ] < n ) j ++ ; else i ++ ; } printf ( \\\" No ▁ such ▁ pair \\\" ) ; return false ; } int main ( ) { int arr [ ] = { 1 , 8 , 30 , 40 , 100 } ; int size = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; int n = 60 ; findPair ( arr , size , n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Program for factorial of a number | C ++ program to find factorial of given number ; single line to find factorial ; Driver Code\\\"\\nSolution in C:\",\"targets\":\"#include \\nint factorial ( int n ) { return ( n == 1 n == 0 ) ? 1 : n * factorial ( n - 1 ) ; } int main ( ) { int num = 5 ; printf ( \\\" Factorial ▁ of ▁ % d ▁ is ▁ % d \\\" , num , factorial ( num ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Count pairs with given sum | Set 2 | C # implementation of the approach ; Function to return the count of pairs from arr [ ] with the given sum ; To store the count of pairs ; Sort the given array ; Take two pointers ; If sum is greater ; If sum is lesser ; If sum is equal ; Find the frequency of arr [ i ] ; Find the frequency of arr [ j ] ; If arr [ i ] and arr [ j ] are same then remove the extra number counted ; Return the required answer ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int pairs_count ( int [ ] arr , int n , int sum ) { int ans = 0 ; Array . Sort ( arr ) ; int i = 0 , j = n - 1 ; while ( i < j ) { if ( arr [ i ] + arr [ j ] < sum ) i ++ ; else if ( arr [ i ] + arr [ j ] > sum ) j -- ; else { int x = arr [ i ] , xx = i ; while ( ( i < j ) && ( arr [ i ] == x ) ) i ++ ; int y = arr [ j ] , yy = j ; while ( ( j >= i ) && ( arr [ j ] == y ) ) j -- ; if ( x == y ) { int temp = i - xx + yy - j - 1 ; ans += ( temp * ( temp + 1 ) ) \\/ 2 ; } else ans += ( i - xx ) * ( yy - j ) ; } } return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 5 , 7 , 5 , - 1 } ; int n = arr . Length ; int sum = 6 ; Console . WriteLine ( pairs_count ( arr , n , sum ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Check if two strings are same ignoring their cases | Function to compare two strings ignoring their cases ; Convert to lowercase using toLowerCase function ; Comparing both using inbuilt function ; if strings are equal , return true otherwise false ; Function to print the same or not same if strings are equal or not equal ; Driver Code\\\"\\nSolution in Javascript:\",\"targets\":\"function equalIgnoreCase ( str1 , str2 ) { let i = 0 ; str1 = str1 . toLowerCase ( ) ; str2 = str2 . toLowerCase ( ) ; let x = ( str1 == ( str2 ) ) ; return x == true ; } function equalIgnoreCaseUtil ( str1 , str2 ) { let res = equalIgnoreCase ( str1 , str2 ) ; if ( res == true ) document . write ( \\\" \\\" ) ; else document . write ( \\\" \\\" ) ; } let str1 , str2 ; str1 = \\\" \\\" ; str2 = \\\" \\\" ; equalIgnoreCaseUtil ( str1 , str2 ) ; str1 = \\\" \\\" ; str2 = \\\" \\\" ; equalIgnoreCaseUtil ( str1 , str2 ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Palindrome Partitioning | DP | C # Code for Palindrome Partitioning Problem ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; public class GFG { static bool isPalindrome ( string String , int i , int j ) { while ( i < j ) { if ( String [ i ] != String [ j ] ) return false ; i ++ ; j -- ; } return true ; } static int minPalPartion ( string String , int i , int j ) { if ( i >= j || isPalindrome ( String , i , j ) ) return 0 ; int ans = Int32 . MaxValue , count ; for ( int k = i ; k < j ; k ++ ) { count = minPalPartion ( String , i , k ) + minPalPartion ( String , k + 1 , j ) + 1 ; ans = Math . Min ( ans , count ) ; } return ans ; } static public void Main ( ) { string str = \\\" ababbbabbababa \\\" ; Console . WriteLine ( \\\" Min ▁ cuts ▁ needed ▁ for ▁ \\\" + \\\" Palindrome ▁ Partitioning ▁ is ▁ \\\" + minPalPartion ( str , 0 , str . Length - 1 ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Program to find whether a given number is power of 2 | ; Function to check if x is power of 2 ; First x in the below expression is for the case when x is 0 ; Driver program to test above function\\\"\\nSolution in C:\",\"targets\":\"#include \\n#define bool int\\nbool isPowerOfTwo ( int x ) { return x && ( ! ( x & ( x - 1 ) ) ) ; } int main ( ) { isPowerOfTwo ( 31 ) ? printf ( \\\" Yes \\n \\\" ) : printf ( \\\" No \\n \\\" ) ; isPowerOfTwo ( 64 ) ? printf ( \\\" Yes \\n \\\" ) : printf ( \\\" No \\n \\\" ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Find the number of cells in the table contains X | Function to find number of cells in the table contains X ; Driver code ; Function call\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def Cells ( n , x ) :\\n\\tans = 0 ;\\n\\tfor i in range ( 1 , n + 1 ) :\\n\\t\\tif ( x % i == 0 and x \\/ i <= n ) :\\n\\t\\t\\tans += 1 ;\\n\\treturn ans ;\\nif __name__ == ' _ _ main _ _ ' :\\n\\tn = 6 ; x = 12 ;\\n\\tprint ( Cells ( n , x ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Maximum types of candies a person can eat if only N \\/ 2 of them can be eaten | Function to find number of candy types ; Declare a hashset to store candies ; Traverse the given array and inserts element into set ; Return the result ; Function to find maximum number of types of candies a person can eat ; Store the number of candies allowed to eat ; Store the number of candy types ; Return the result ; Given Input ; Function Call\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function num_candyTypes ( candies ) { let s = new Set ( ) ; for ( let i = 0 ; i < candies . length ; i ++ ) { s . add ( candies [ i ] ) ; } return s . size ; } function distribute_candies ( candies ) { let allowed = candies . length \\/ 2 ; let types = num_candyTypes ( candies ) ; if ( types < allowed ) document . write ( types ) ; else document . write ( allowed ) ; } let candies = [ 4 , 4 , 5 , 5 , 3 , 3 ] ; distribute_candies ( candies ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Print N numbers such that their product is a Perfect Cube | Function to find the N numbers such that their product is a perfect cube ; Loop to traverse each number from 1 to N ; Print the cube of i as the ith term of the output ; Driver Code ; Function Call\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function findNumbers ( N ) { let i = 1 ; while ( i <= N ) { document . write ( ( i * i * i ) + \\\" \\\" ) ; i ++ ; } } let N = 4 ; findNumbers ( N ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Maximum sum such that no two elements are adjacent | Set 2 | C # program to implement above approach ; variable to store states of dp ; variable to check if a given state has been solved ; Function to find the maximum sum subsequence such that no two elements are adjacent ; Base case ; To check if a state has been solved ; Required recurrence relation ; Returning the value ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int maxLen = 10 ; static int [ ] dp = new int [ maxLen ] ; static bool [ ] v = new bool [ maxLen ] ; static int maxSum ( int [ ] arr , int i , int n ) { if ( i >= n ) return 0 ; if ( v [ i ] ) return dp [ i ] ; v [ i ] = true ; dp [ i ] = Math . Max ( maxSum ( arr , i + 1 , n ) , arr [ i ] + maxSum ( arr , i + 2 , n ) ) ; return dp [ i ] ; } public static void Main ( ) { int [ ] arr = { 12 , 9 , 7 , 33 } ; int n = arr . Length ; Console . Write ( maxSum ( arr , 0 , n ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"Calculate 7 n \\/ 8 without using division and multiplication operators | C program to evaluate 7 n \\/ 8 without using * and \\/ ; Step 1 ) First multiply number by 7 i . e . 7 n = ( n << 3 ) - n * Step 2 ) Divide result by 8 ; Driver program to test above function\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint multiplyBySevenByEight ( unsigned int n ) { return ( ( n << 3 ) - n ) >> 3 ; } int main ( ) { unsigned int n = 15 ; printf ( \\\" % u \\\" , multiplyBySevenByEight ( n ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Check if a given string can be converted to another by given possible swaps | C # program to implement the above approach ; Stores length of str1 ; Stores length of str2 ; Stores distinct characters of str1 ; Stores distinct characters of str2 ; Stores frequency of each character of str1 ; Traverse the String str1 ; Update frequency of str1 [ i ] ; Traverse the String str1 ; Insert str1 [ i ] into st1 ; Traverse the String str2 ; Insert str1 [ i ] into st1 ; If distinct characters in str1 and str2 are not same ; Stores frequency of each character of str2 ; Traverse the String str2 ; Update frequency of str2 [ i ] ; Sort hash1 [ ] array ; Sort hash2 [ ] array ; Traverse hash1 [ ] and hash2 [ ] ; If hash1 [ i ] not equal to hash2 [ i ] ; Driver Code\\\"\\nSolution in C#:\",\"targets\":\"using System ; using System . Collections . Generic ; class GFG { static bool checkStr1CanConStr2 ( String str1 , String str2 ) { int N = str1 . Length ; int M = str2 . Length ; HashSet < int > st1 = new HashSet < int > ( ) ; HashSet < int > st2 = new HashSet < int > ( ) ; int [ ] hash1 = new int [ 256 ] ; for ( int i = 0 ; i < N ; i ++ ) { hash1 [ str1 [ i ] ] ++ ; } for ( int i = 0 ; i < N ; i ++ ) { st1 . Add ( str1 [ i ] ) ; } for ( int i = 0 ; i < M ; i ++ ) { st2 . Add ( str2 [ i ] ) ; } if ( st1 . Equals ( st2 ) ) { return false ; } int [ ] hash2 = new int [ 256 ] ; for ( int i = 0 ; i < M ; i ++ ) { hash2 [ str2 [ i ] ] ++ ; } Array . Sort ( hash1 ) ; Array . Sort ( hash2 ) ; for ( int i = 0 ; i < 256 ; i ++ ) { if ( hash1 [ i ] != hash2 [ i ] ) { return false ; } } return true ; } public static void Main ( String [ ] args ) { String str1 = \\\" xyyzzlll \\\" ; String str2 = \\\" yllzzxxx \\\" ; if ( checkStr1CanConStr2 ( str1 , str2 ) ) { Console . Write ( \\\" True \\\" ) ; } else { Console . Write ( \\\" False \\\" ) ; } } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Count of N | Function to find count of N - digit numbers with single digit XOR ; Range of numbers ; Calculate XOR of digits ; If XOR <= 9 , then increment count ; Print the count ; Given number ; Function call\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function countNums ( N ) { let l = Math . floor ( Math . pow ( 10 , N - 1 ) ) ; let r = Math . floor ( Math . pow ( 10 , N ) ) - 1 ; let count = 0 ; for ( let i = l ; i <= r ; i ++ ) { let xorr = 0 , temp = i ; while ( temp > 0 ) { xorr = xorr ^ ( temp % 10 ) ; temp = Math . floor ( temp \\/ 10 ) ; } if ( xorr <= 9 ) count ++ ; } document . write ( count ) ; } let N = 2 ; countNums ( N ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"Write a program to reverse digits of a number | C program to reverse digits of a number ; Recursive function to reverse digits of num ; Driver program to test reversDigits\\nHow can the above be solved in C?\",\"targets\":\"#include ; int reversDigits ( int num ) { static int rev_num = 0 ; static int base_pos = 1 ; if ( num > 0 ) { reversDigits ( num \\/ 10 ) ; rev_num += ( num % 10 ) * base_pos ; base_pos *= 10 ; } return rev_num ; } int main ( ) { int num = 4562 ; printf ( \\\" Reverse ▁ of ▁ no . ▁ is ▁ % d \\\" , reversDigits ( num ) ) ; getchar ( ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"Modular Exponentiation ( Power in Modular Arithmetic ) | Iterative Function to calculate ( x ^ y ) in O ( log y ) ; Initialize result ; If y is odd , multiply x with result ; y must be even now y = y \\/ 2 ; Change x to x ^ 2\\nHow can the above be solved in C?\",\"targets\":\"int power ( int x , unsigned int y ) { int res = 1 ; while ( y > 0 ) { if ( y & 1 ) res = res * x ; y = y >> 1 ; x = x * x ; } return res ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Bitwise OR of Bitwise AND of all subarrays of an array | Function to find the Bitwise OR of Bitwise AND of all subarrays ; Stores the required result ; Generate all the subarrays ; Store the current element ; Find the Bitwise OR ; Update the result ; Print the result ; Driver Code\\\"\\nSolution in Javascript:\",\"targets\":\"function findbitwiseOR ( a , n ) { let res = 0 ; for ( let i = 0 ; i < n ; i ++ ) { let curr_sub_array = a [ i ] ; res = res | curr_sub_array ; for ( let j = i ; j < n ; j ++ ) { curr_sub_array = curr_sub_array & a [ j ] ; res = res | curr_sub_array ; } } document . write ( res ) ; } let A = [ 1 , 2 , 3 ] ; let N = A . length ; findbitwiseOR ( A , N ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Wasteful Numbers | C ++ program for the above approach ; Array to store all prime less than and equal to MAX . ; Function for Sieve of Sundaram ; Boolean Array ; Mark all numbers which do not generate prime number by 2 * i + 1 ; Since 2 is a prime number ; Print remaining primes are of the form 2 * i + 1 such that marked [ i ] is false . ; Function that returns true if n is a Wasteful number ; Count digits in original number ; Count all digits in prime factors of N pDigit is going to hold this value . ; Count powers of p in n ; If primes [ i ] is a prime factor , ; Count the power of prime factors ; Add its digits to pDigit ; Add digits of power of prime factors to pDigit . ; If n != 1 then one prime factor still to be summed up ; If digits in prime factors is more than digits in original number then return true . Else return false . ; Function to print Wasteful Number before N ; Iterate till N and check if i is wastefull or not ; Driver code ; Precompute prime numbers upto 10 ^ 6 ; Function Call\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; const int MAX = 10000 ; vector < int > primes ; void sieveSundaram ( ) { bool marked [ MAX \\/ 2 + 1 ] = { 0 } ; for ( int i = 1 ; i <= ( sqrt ( MAX ) - 1 ) \\/ 2 ; i ++ ) { for ( int j = ( i * ( i + 1 ) ) << 1 ; j <= MAX \\/ 2 ; j = j + 2 * i + 1 ) { marked [ j ] = true ; } } primes . push_back ( 2 ) ; for ( int i = 1 ; i <= MAX \\/ 2 ; i ++ ) if ( marked [ i ] == false ) primes . push_back ( 2 * i + 1 ) ; } bool isWasteful ( int n ) { if ( n == 1 ) return false ; int original_no = n ; int sumDigits = 0 ; while ( original_no > 0 ) { sumDigits ++ ; original_no = original_no \\/ 10 ; } int pDigit = 0 , count_exp = 0 , p ; for ( int i = 0 ; primes [ i ] <= n \\/ 2 ; i ++ ) { while ( n % primes [ i ] == 0 ) { p = primes [ i ] ; n = n \\/ p ; count_exp ++ ; } while ( p > 0 ) { pDigit ++ ; p = p \\/ 10 ; } while ( count_exp > 1 ) { pDigit ++ ; count_exp = count_exp \\/ 10 ; } } if ( n != 1 ) { while ( n > 0 ) { pDigit ++ ; n = n \\/ 10 ; } } return ( pDigit > sumDigits ) ; } void Solve ( int N ) { for ( int i = 1 ; i < N ; i ++ ) { if ( isWasteful ( i ) ) { cout << i << \\\" ▁ \\\" ; } } } int main ( ) { sieveSundaram ( ) ; int N = 10 ; Solve ( N ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Find Corners of Rectangle using mid points | C ++ program to find corner points of a rectangle using given length and middle points . ; Structure to represent a co - ordinate point ; This function receives two points and length of the side of rectangle and prints the 4 corner points of the rectangle ; horizontal rectangle ; vertical rectangle ; slanted rectangle ; calculate slope of the side ; calculate displacements along axes ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; struct Point { float x , y ; Point ( ) { x = y = 0 ; } Point ( float a , float b ) { x = a , y = b ; } } ; void printCorners ( Point p , Point q , float l ) { Point a , b , c , d ; if ( p . x == q . x ) { a . x = p . x - ( l \\/ 2.0 ) ; a . y = p . y ; d . x = p . x + ( l \\/ 2.0 ) ; d . y = p . y ; b . x = q . x - ( l \\/ 2.0 ) ; b . y = q . y ; c . x = q . x + ( l \\/ 2.0 ) ; c . y = q . y ; } else if ( p . y == q . y ) { a . y = p . y - ( l \\/ 2.0 ) ; a . x = p . x ; d . y = p . y + ( l \\/ 2.0 ) ; d . x = p . x ; b . y = q . y - ( l \\/ 2.0 ) ; b . x = q . x ; c . y = q . y + ( l \\/ 2.0 ) ; c . x = q . x ; } else { float m = ( p . x - q . x ) \\/ float ( q . y - p . y ) ; float dx = ( l \\/ sqrt ( 1 + ( m * m ) ) ) * 0.5 ; float dy = m * dx ; a . x = p . x - dx ; a . y = p . y - dy ; d . x = p . x + dx ; d . y = p . y + dy ; b . x = q . x - dx ; b . y = q . y - dy ; c . x = q . x + dx ; c . y = q . y + dy ; } cout << a . x << \\\" , ▁ \\\" << a . y << \\\" ▁ n \\\" << b . x << \\\" , ▁ \\\" << b . y << \\\" n \\\" ; << c . x << \\\" , ▁ \\\" << c . y << \\\" ▁ n \\\" << d . x << \\\" , ▁ \\\" << d . y << \\\" nn \\\" ; } int main ( ) { Point p1 ( 1 , 0 ) , q1 ( 1 , 2 ) ; printCorners ( p1 , q1 , 2 ) ; Point p ( 1 , 1 ) , q ( -1 , -1 ) ; printCorners ( p , q , 2 * sqrt ( 2 ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Find the repeating and the missing | Added 3 new methods | C program to Find the repeating and missing elements ; Driver code\\\"\\nSolution in C:\",\"targets\":\"#include \\n#include \\nvoid printTwoElements ( int arr [ ] , int size ) { int i ; printf ( \\\" The repeating element is \\\" for ( i = 0 ; i < size ; i ++ ) { if ( arr [ abs ( arr [ i ] ) - 1 ] > 0 ) arr [ abs ( arr [ i ] ) - 1 ] = - arr [ abs ( arr [ i ] ) - 1 ] ; else printf ( \\\" ▁ % d ▁ \\\" , abs ( arr [ i ] ) ) ; } printf ( \\\" and the missing element is \\\" for ( i = 0 ; i < size ; i ++ ) { if ( arr [ i ] > 0 ) printf ( \\\" % d \\\" , i + 1 ) ; } } int main ( ) { int arr [ ] = { 7 , 3 , 4 , 5 , 5 , 6 , 2 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; printTwoElements ( arr , n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Find the day number in the current year for the given date | C # implementation of the approach ; Function to return the day number of the year for the given date ; Extract the year , month and the day from the date string ; If current year is a leap year and the date given is after the 28 th of February then it must include the 29 th February ; Add the days in the previous months ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static int [ ] days = { 31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 } ; static int dayOfYear ( string date ) { int year = Int32 . Parse ( date . Substring ( 0 , 4 ) ) ; int month = Int32 . Parse ( date . Substring ( 5 , 2 ) ) ; int day = Int32 . Parse ( date . Substring ( 8 ) ) ; if ( month > 2 && year % 4 == 0 && ( year % 100 != 0 year % 400 == 0 ) ) { ++ day ; } while ( -- month > 0 ) { day = day + days [ month - 1 ] ; } return day ; } public static void Main ( ) { String date = \\\"2019-01-09\\\" ; Console . WriteLine ( dayOfYear ( date ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"Subtract two numbers without using arithmetic operators | ; Driver program\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint subtract ( int x , int y ) { if ( y == 0 ) return x ; return subtract ( x ^ y , ( ~ x & y ) << 1 ) ; } int main ( ) { int x = 29 , y = 13 ; printf ( \\\" x ▁ - ▁ y ▁ is ▁ % d \\\" , subtract ( x , y ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Threaded Binary Search Tree | Deletion | Complete C # program to demonstrate deletion in threaded BST ; True if left pointer points to predecessor in Inorder Traversal ; True if right pointer points to predecessor in Inorder Traversal ; Insert a Node in Binary Threaded Tree ; Searching for a Node with given value ; Parent of key to be inserted ; If key already exists , return ; Update parent pointer ; Moving on left subtree . ; Moving on right subtree . ; Create a new Node ; Returns inorder successor using left and right children ( Used in deletion ) ; Returns inorder successor using rthread ( Used in inorder ) ; If rthread is set , we can quickly find ; Else return leftmost child of right subtree ; Printing the threaded tree ; Reach leftmost Node ; One by one print successors ; Here ' par ' is pointer to parent Node and ' ptr ' is pointer to current Node . ; If Node to be deleted is root ; If Node to be deleted is left of its parent ; Here ' par ' is pointer to parent Node and ' ptr ' is pointer to current Node . ; Initialize child Node to be deleted has left child . ; Node to be deleted has right child . ; Node to be deleted is root Node . ; Node is left child of its parent . ; Find successor and predecessor ; If ptr has left subtree . ; If ptr has right subtree . ; Here ' par ' is pointer to parent Node and ' ptr ' is pointer to current Node . ; Find inorder successor and its parent . ; Find leftmost child of successor ; Deletes a key from threaded BST with given root and returns new root of BST . ; Initialize parent as null and ptrent Node as root . ; Set true if key is found ; Search key in BST : find Node and its parent . ; Two Children ; Only Left Child ; Only Right Child ; No child ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { public class Node { public Node left , right ; public int info ; public bool lthread ; public bool rthread ; } ; static Node insert ( Node root , int ikey ) { Node ptr = root ; Node par = null ; while ( ptr != null ) { if ( ikey == ( ptr . info ) ) { Console . Write ( \\\" Duplicate ▁ Key ▁ ! \\n \\\" ) ; return root ; } par = ptr ; if ( ikey < ptr . info ) { if ( ptr . lthread == false ) ptr = ptr . left ; else break ; } else { if ( ptr . rthread == false ) ptr = ptr . right ; else break ; } } Node tmp = new Node ( ) ; tmp . info = ikey ; tmp . lthread = true ; tmp . rthread = true ; if ( par == null ) { root = tmp ; tmp . left = null ; tmp . right = null ; } else if ( ikey < ( par . info ) ) { tmp . left = par . left ; tmp . right = par ; par . lthread = false ; par . left = tmp ; } else { tmp . left = par ; tmp . right = par . right ; par . rthread = false ; par . right = tmp ; } return root ; } static Node inSucc ( Node ptr ) { if ( ptr . rthread == true ) return ptr . right ; ptr = ptr . right ; while ( ptr . lthread == false ) ptr = ptr . left ; return ptr ; } static Node inorderSuccessor ( Node ptr ) { if ( ptr . rthread == true ) return ptr . right ; ptr = ptr . right ; while ( ptr . lthread == false ) ptr = ptr . left ; return ptr ; } static void inorder ( Node root ) { if ( root == null ) Console . Write ( \\\" Tree ▁ is ▁ empty \\\" ) ; Node ptr = root ; while ( ptr . lthread == false ) ptr = ptr . left ; while ( ptr != null ) { Console . Write ( \\\" { 0 } ▁ \\\" , ptr . info ) ; ptr = inorderSuccessor ( ptr ) ; } } static Node inPred ( Node ptr ) { if ( ptr . lthread == true ) return ptr . left ; ptr = ptr . left ; while ( ptr . rthread == false ) ptr = ptr . right ; return ptr ; } static Node caseA ( Node root , Node par , Node ptr ) { if ( par == null ) root = null ; else if ( ptr == par . left ) { par . lthread = true ; par . left = ptr . left ; } else { par . rthread = true ; par . right = ptr . right ; } return root ; } static Node caseB ( Node root , Node par , Node ptr ) { Node...\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Subtract two numbers without using arithmetic operators | ; Driver program\\\"\\nSolution in C:\",\"targets\":\"#include \\nint subtract ( int x , int y ) { if ( y == 0 ) return x ; return subtract ( x ^ y , ( ~ x & y ) << 1 ) ; } int main ( ) { int x = 29 , y = 13 ; printf ( \\\" x ▁ - ▁ y ▁ is ▁ % d \\\" , subtract ( x , y ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Pascal 's Triangle | A O ( n ^ 2 ) time and O ( n ^ 2 ) extra space method for Pascal 's Triangle ; An auxiliary array to store generated pscal triangle values ; Iterate through every line and print integer ( s ) in it ; Every line has number of integers equal to line number ; First and last values in every row are 1 ; Other values are sum of values just above and left of above ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function printPascal ( $ n ) { $ arr = array ( array ( ) ) ; for ( $ line = 0 ; $ line < $ n ; $ line ++ ) { for ( $ i = 0 ; $ i <= $ line ; $ i ++ ) { if ( $ line == $ i $ i == 0 ) $ arr [ $ line ] [ $ i ] = 1 ; else $ arr [ $ line ] [ $ i ] = $ arr [ $ line - 1 ] [ $ i - 1 ] + $ arr [ $ line - 1 ] [ $ i ] ; echo $ arr [ $ line ] [ $ i ] . \\\" \\\" ; } echo \\\" \\n \\\" ; } } $ n = 5 ; printPascal ( $ n ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Maximum possible prime divisors that can exist in numbers having exactly N divisors | Function to find the maximum possible prime divisors of a number can have with N divisors ; Number of time number divided by 2 ; Divide by other prime numbers ; If the last number of also prime then also include it ; Driver Code ; Function Call\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function findMaxPrimeDivisor ( n ) { let max_possible_prime = 0 ; while ( n % 2 == 0 ) { max_possible_prime ++ ; n = Math . floor ( n \\/ 2 ) ; } for ( let i = 3 ; i * i <= n ; i = i + 2 ) { while ( n % i == 0 ) { max_possible_prime ++ ; n = Math . floor ( n \\/ i ) ; } } if ( n > 2 ) { max_possible_prime ++ ; } document . write ( max_possible_prime + \\\" \\\" ) ; } let n = 4 ; findMaxPrimeDivisor ( n ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Number of minimum length paths between 1 to N including each node | C ++ program for the above approach ; Function to calculate the distances from node 1 to N ; Stores the number of edges ; Storing the edges in vector ; Initialize queue ; BFS from 1 st node using queue ; Pop from queue ; Traversing the adjacency list ; Initialize queue ; BFS from last node ; Pop from queue ; Traverse the adjacency list ; Print the count of minimum distance ; Driver Code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; #define ll long long int\\nvoid countMinDistance ( int n , int m , int edges [ ] [ 2 ] ) { vector < ll > g [ 10005 ] ; for ( int i = 0 ; i < m ; i ++ ) { int a = edges [ i ] [ 0 ] - 1 ; int b = edges [ i ] [ 1 ] - 1 ; g [ a ] . push_back ( b ) ; g [ b ] . push_back ( a ) ; } queue < pair < ll , ll > > queue1 ; queue1 . push ( { 0 , 0 } ) ; vector < int > dist ( n , 1e9 ) ; vector < int > ways1 ( n , 0 ) ; dist [ 0 ] = 0 ; ways1 [ 0 ] = 1 ; while ( ! queue1 . empty ( ) ) { auto up = queue1 . front ( ) ; queue1 . pop ( ) ; int x = up . first ; int dis = up . second ; if ( dis > dist [ x ] ) continue ; if ( x == n - 1 ) continue ; for ( ll y : g [ x ] ) { if ( dist [ y ] > dis + 1 ) { dist [ y ] = dis + 1 ; ways1 [ y ] = ways1 [ x ] ; queue1 . push ( { y , dis + 1 } ) ; } else if ( dist [ y ] == dis + 1 ) { ways1 [ y ] += ways1 [ x ] ; } } } queue < pair < ll , ll > > queue2 ; queue2 . push ( { n - 1 , 0 } ) ; vector < int > dist1 ( n , 1e9 ) ; vector < int > ways2 ( n , 0 ) ; dist1 [ n - 1 ] = 0 ; ways2 [ n - 1 ] = 1 ; while ( ! queue2 . empty ( ) ) { auto up = queue2 . front ( ) ; queue2 . pop ( ) ; int x = up . first ; int dis = up . second ; if ( dis > dist1 [ x ] ) continue ; if ( x == 0 ) continue ; for ( ll y : g [ x ] ) { if ( dist1 [ y ] > dis + 1 ) { dist1 [ y ] = dis + 1 ; ways2 [ y ] = ways2 [ x ] ; queue2 . push ( { y , dis + 1 } ) ; } else if ( dist1 [ y ] == 1 + dis ) { ways2 [ y ] += ways2 [ x ] ; } } } for ( int i = 0 ; i < n ; i ++ ) { cout << ways1 [ i ] * ways2 [ i ] << \\\" ▁ \\\" ; } } int main ( ) { int N = 5 , M = 5 ; int edges [ M ] [ 2 ] = { { 1 , 2 } , { 1 , 4 } , { 1 , 3 } , { 2 , 5 } , { 2 , 4 } } ; countMinDistance ( N , M , edges ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Remove minimum numbers from the array to get minimum OR value | C ++ implementation of the approach ; Function to return the minimum deletions to get minimum OR ; To store the minimum element ; Find the minimum element from the array ; To store the frequency of the minimum element ; Find the frequency of the minimum element ; Return the final answer ; Driver code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int findMinDel ( int * arr , int n ) { int min_num = INT_MAX ; for ( int i = 0 ; i < n ; i ++ ) min_num = min ( arr [ i ] , min_num ) ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] == min_num ) cnt ++ ; return n - cnt ; } int main ( ) { int arr [ ] = { 3 , 3 , 2 } ; int n = sizeof ( arr ) \\/ sizeof ( int ) ; cout << findMinDel ( arr , n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Count of integers up to N which represent a Binary number | Java program to count the number of integers upto N which are of the form of binary representations ; Function to return the count ; If the current last digit is 1 ; Add 2 ^ ( ctr - 1 ) possible integers to the answer ; If the current digit exceeds 1 ; Set answer as 2 ^ ctr - 1 as all possible binary integers with ctr number of digits can be obtained ; Driver Code\\\"\\nSolution in Java:\",\"targets\":\"import java . util . * ; class GFG { static int countBinaries ( int N ) { int ctr = 1 ; int ans = 0 ; while ( N > 0 ) { if ( N % 10 == 1 ) { ans += Math . pow ( 2 , ctr - 1 ) ; } else if ( N % 10 > 1 ) { ans = ( int ) ( Math . pow ( 2 , ctr ) - 1 ) ; } ctr ++ ; N \\/= 10 ; } return ans ; } public static void main ( String [ ] args ) { int N = 20 ; System . out . print ( countBinaries ( N ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Equation of ellipse from its focus , directrix , and eccentricity | C # program to find equation of an ellipse using focus and directrix . ; Function to find equation of ellipse . ; Driver Code\\\"\\nSolution in C#:\",\"targets\":\"class solution { static void equation_ellipse ( float x1 , float y1 , float a , float b , float c , float e ) { float t = a * a + b * b ; float a1 = t - e * ( a * a ) ; float b1 = t - e * ( b * b ) ; float c1 = ( - 2 * t * x1 ) - ( 2 * e * c * a ) ; float d1 = ( - 2 * t * y1 ) - ( 2 * e * c * b ) ; float e1 = - 2 * e * a * b ; float f1 = ( - e * c * c ) + ( t * x1 * x1 ) + ( t * y1 * y1 ) ; System . Console . WriteLine ( \\\" Equation ▁ of ▁ ellipse ▁ is ▁ \\\" ) ; System . Console . WriteLine ( a1 + \\\" ▁ x ^ 2 ▁ + ▁ \\\" + b1 + \\\" ▁ y ^ 2 ▁ + ▁ \\\" + c1 + \\\" ▁ x ▁ + ▁ \\\" + d1 + \\\" ▁ y ▁ + ▁ \\\" + e1 + \\\" ▁ xy ▁ + ▁ \\\" + f1 + \\\" ▁ = ▁ 0\\\" ) ; } public static void Main ( ) { float x1 = 1 , y1 = 1 , a = 1 , b = - 1 , c = 3 , e = ( float ) 0.5 * ( float ) 0.5 ; equation_ellipse ( x1 , y1 , a , b , c , e ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Maximize sum of array elements removed by performing the given operations | Javascript program for the above approach ; Function to find the maximum sum of the array arr [ ] where each element can be reduced to at most min [ i ] ; Stores the pair of arr [ i ] & min [ i ] ; Sorting vector of pairs ; Traverse the vector of pairs ; Add to the value of S ; Update K ; Driver Code ; Given array arr [ ] , min [ ] ; Given K ; Function Call ; Print the value of S\\\"\\nSolution in Javascript:\",\"targets\":\"var S = 0 ; function findMaxSum ( arr , n , min , k ) { var A = [ ] ; for ( var i = 0 ; i < n ; i ++ ) { A . push ( [ arr [ i ] , min [ i ] ] ) ; } A . sort ( ( a , b ) => b [ 0 ] - a [ 0 ] ) ; var K = 0 ; for ( var i = 0 ; i < n ; i ++ ) { S += Math . max ( A [ i ] [ 0 ] - K , A [ i ] [ 1 ] ) ; K += k ; } } var arr = [ ] , min = [ ] ; arr = [ 3 , 5 , 2 , 1 ] ; min = [ 3 , 2 , 1 , 3 ] ; var N = arr . length ; var K = 3 ; findMaxSum ( arr , N , min , K , S ) ; document . write ( S ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Minimize the sum of product of two arrays with permutations allowed | Java program to calculate minimum sum of product of two arrays . ; Returns minimum sum of product of two arrays with permutations allowed ; Sort A and B so that minimum and maximum value can easily be fetched . ; Multiplying minimum value of A and maximum value of B ; Driven Code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . io . * ; import java . util . * ; class GFG { static long minValue ( int A [ ] , int B [ ] , int n ) { Arrays . sort ( A ) ; Arrays . sort ( B ) ; long result = 0 ; for ( int i = 0 ; i < n ; i ++ ) result += ( A [ i ] * B [ n - i - 1 ] ) ; return result ; } public static void main ( String [ ] args ) { int A [ ] = { 3 , 1 , 1 } ; int B [ ] = { 6 , 5 , 4 } ; int n = A . length ; ; System . out . println ( minValue ( A , B , n ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Longest subarray not having more than K distinct elements | function to print the longest sub - array ; mark the element visited ; if its visited first time , then increase the counter of distinct elements by 1 ; When the counter of distinct elements increases from k , then reduce it to k ; from the left , reduce the number of time of visit ; if the reduced visited time element is not present in further segment then decrease the count of distinct elements ; increase the subsegment mark ; check length of longest sub - segment when greater then previous best then change it ; print the longest sub - segment ; driver program to test the above function\\\"\\nSolution in Javascript:\",\"targets\":\"function longest ( a , n , k ) { var freq = Array ( 7 ) . fill ( 0 ) ; var start = 0 , end = 0 , now = 0 , l = 0 ; for ( var i = 0 ; i < n ; i ++ ) { freq [ a [ i ] ] ++ ; if ( freq [ a [ i ] ] == 1 ) now ++ ; while ( now > k ) { freq [ a [ l ] ] -- ; if ( freq [ a [ l ] ] == 0 ) now -- ; l ++ ; } if ( i - l + 1 >= end - start + 1 ) { end = i ; start = l ; } } for ( var i = start ; i <= end ; i ++ ) document . write ( a [ i ] + \\\" \\\" ) ; } var a = [ 6 , 5 , 1 , 2 , 3 , 2 , 1 , 4 , 5 ] ; var n = a . length ; var k = 3 ; longest ( a , n , k ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Alternate Odd and Even Nodes in a Singly Linked List | Structure node ; A utility function to print linked list ; Function to create newNode in a linkedlist ; Function to insert at beginning ; Function to rearrange the odd and even nodes ; Step 1 : Segregate even and odd nodes Step 2 : Split odd and even lists Step 3 : Merge even list into odd list ; Step 1 : Segregate Odd and Even Nodes ; Backup next pointer of temp ; If temp is odd move the node to beginning of list ; Advance Temp Pointer ; Step 2 Split the List into Odd and even ; End the odd List ( Make last node None ) ; Step 3 : Merge Even List into odd ; While both lists are not exhausted Backup next pointers of i and j ; ptr points to the latest node added ; Advance i and j pointers ; Odd list exhausts before even , append remainder of even list to odd . ; The case where even list exhausts before odd list is automatically handled since we merge the even list into the odd list ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"class Node :\\n\\tdef __init__ ( self ) :\\n\\t\\tself . data = 0\\n\\t\\tself . next = None\\ndef printList ( node ) :\\n\\twhile ( node != None ) :\\n\\t\\tprint ( node . data , end = \\\" ▁ \\\" )\\n\\t\\tnode = node . next\\n\\tprint ( \\\" ▁ \\\" )\\ndef newNode ( key ) :\\n\\ttemp = Node ( )\\n\\ttemp . data = key\\n\\ttemp . next = None\\n\\treturn temp\\ndef insertBeg ( head , val ) :\\n\\ttemp = newNode ( val )\\n\\ttemp . next = head\\n\\thead = temp\\n\\treturn head\\ndef rearrange ( head ) :\\n\\teven = None\\n\\ttemp = None\\n\\tprev_temp = None\\n\\ti = None\\n\\tj = None\\n\\tk = None\\n\\tl = None\\n\\tptr = None\\n\\ttemp = ( head ) . next\\n\\tprev_temp = head\\n\\twhile ( temp != None ) :\\n\\t\\tx = temp . next\\n\\t\\tif ( temp . data % 2 != 0 ) :\\n\\t\\t\\tprev_temp . next = x\\n\\t\\t\\ttemp . next = ( head )\\n\\t\\t\\t( head ) = temp\\n\\t\\telse :\\n\\t\\t\\tprev_temp = temp\\n\\t\\ttemp = x\\n\\ttemp = ( head ) . next\\n\\tprev_temp = ( head )\\n\\twhile ( temp != None and temp . data % 2 != 0 ) :\\n\\t\\tprev_temp = temp\\n\\t\\ttemp = temp . next\\n\\teven = temp\\n\\tprev_temp . next = None\\n\\ti = head\\n\\tj = even\\n\\twhile ( j != None and i != None ) :\\n\\t\\tk = i . next\\n\\t\\tl = j . next\\n\\t\\ti . next = j\\n\\t\\tj . next = k\\n\\t\\tptr = j\\n\\t\\ti = k\\n\\t\\tj = l\\n\\tif ( i == None ) :\\n\\t\\tptr . next = j\\n\\treturn head\\nhead = newNode ( 8 )\\nhead = insertBeg ( head , 7 )\\nhead = insertBeg ( head , 6 )\\nhead = insertBeg ( head , 3 )\\nhead = insertBeg ( head , 5 )\\nhead = insertBeg ( head , 1 )\\nhead = insertBeg ( head , 2 )\\nhead = insertBeg ( head , 10 )\\nprint ( \\\" Linked ▁ List : \\\" )\\nprintList ( head )\\nprint ( \\\" Rearranged ▁ List \\\" )\\nhead = rearrange ( head )\\nprintList ( head )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Print all pairs with given sum | C ++ implementation of simple method to find count of pairs with given sum . ; Returns number of pairs in arr [ 0. . n - 1 ] with sum equal to ' sum ' ; Store counts of all elements in map m ; Traverse through all elements ; Search if a pair can be formed with arr [ i ] . ; Driver function to test the above function\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; void printPairs ( int arr [ ] , int n , int sum ) { unordered_map < int , int > m ; for ( int i = 0 ; i < n ; i ++ ) { int rem = sum - arr [ i ] ; if ( m . find ( rem ) != m . end ( ) ) { int count = m [ rem ] ; for ( int j = 0 ; j < count ; j ++ ) cout << \\\" ( \\\" << rem << \\\" , ▁ \\\" << arr [ i ] << \\\" ) \\\" << endl ; } m [ arr [ i ] ] ++ ; } } int main ( ) { int arr [ ] = { 1 , 5 , 7 , -1 , 5 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; int sum = 6 ; printPairs ( arr , n , sum ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Maximum size subset with given sum | A Dynamic Programming solution for subset sum problem + maximal subset value . ; Returns size of maximum sized subset if there is a subset of set [ ] with sun equal to given sum . It returns - 1 if there is no subset with given sum . ; The value of subset [ i ] [ j ] will be true if there is a subset of set [ 0. . j - 1 ] with sum equal to i ; If sum is 0 , then answer is true ; If sum is not 0 and set is empty , then answer is false ; Fill the subset table in bottom up manner ; Driver program to test above function\\\"\\nSolution in Java:\",\"targets\":\"class sumofSub { static int isSubsetSum ( int set [ ] , int n , int sum ) { boolean subset [ ] [ ] = new boolean [ sum + 1 ] [ n + 1 ] ; int count [ ] [ ] = new int [ sum + 1 ] [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { subset [ 0 ] [ i ] = true ; count [ 0 ] [ i ] = 0 ; } for ( int i = 1 ; i <= sum ; i ++ ) { subset [ i ] [ 0 ] = false ; count [ i ] [ 0 ] = - 1 ; } for ( int i = 1 ; i <= sum ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { subset [ i ] [ j ] = subset [ i ] [ j - 1 ] ; count [ i ] [ j ] = count [ i ] [ j - 1 ] ; if ( i >= set [ j - 1 ] ) { subset [ i ] [ j ] = subset [ i ] [ j ] || subset [ i - set [ j - 1 ] ] [ j - 1 ] ; if ( subset [ i ] [ j ] ) count [ i ] [ j ] = Math . max ( count [ i ] [ j - 1 ] , count [ i - set [ j - 1 ] ] [ j - 1 ] + 1 ) ; } } } return count [ sum ] [ n ] ; } public static void main ( String args [ ] ) { int set [ ] = { 2 , 3 , 5 , 10 } ; int sum = 20 ; int n = set . length ; System . out . println ( isSubsetSum ( set , n , sum ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"Count set bits in an integer | C program to Count set bits in an integer ; Function to get no of set bits in binary representation of positive integer n ; Program to test function countSetBits\\nHow can the above be solved in C?\",\"targets\":\"#include \\nunsigned int countSetBits ( unsigned int n ) { unsigned int count = 0 ; while ( n ) { count += n & 1 ; n >>= 1 ; } return count ; } int main ( ) { int i = 9 ; printf ( \\\" % d \\\" , countSetBits ( i ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"All about Bit Manipulation | Function to clear the ith bit of the given number N ; Create the mask for the ith bit unset ; Return the update value\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def clearBit ( num , i ) :\\n\\tmask = ~ ( 1 << i )\\n\\treturn num & mask\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Lower Insertion Point | Function to return the lower insertion point of an element in a sorted array ; Base cases ; Final check for the remaining elements which are < X ; Driver code\\\"\\nSolution in Python:\",\"targets\":\"def LowerInsertionPoint ( arr , n , X ) :\\n\\tif ( X < arr [ 0 ] ) :\\n\\t\\treturn 0 ;\\n\\telif ( X > arr [ n - 1 ] ) :\\n\\t\\treturn n\\n\\tlowerPnt = 0\\n\\ti = 1\\n\\twhile ( i < n and arr [ i ] < X ) :\\n\\t\\tlowerPnt = i\\n\\t\\ti = i * 2\\n\\twhile ( lowerPnt < n and arr [ lowerPnt ] < X ) :\\n\\t\\tlowerPnt += 1\\n\\treturn lowerPnt\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tarr = [ 2 , 3 , 4 , 4 , 5 , 6 , 7 , 9 ]\\n\\tn = len ( arr )\\n\\tX = 4\\n\\tprint ( LowerInsertionPoint ( arr , n , X ) )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Find a specific pair in Matrix | An efficient method to find maximum value of mat [ d ] - ma [ a ] [ b ] such that c > a and d > b ; The function returns maximum value A ( c , d ) - A ( a , b ) over all choices of indexes such that both c > a and d > b . ; stores maximum value ; maxArr [ i ] [ j ] stores max of elements in matrix from ( i , j ) to ( N - 1 , N - 1 ) ; last element of maxArr will be same 's as of the input matrix ; preprocess last row Initialize max ; preprocess last column Initialize max ; preprocess rest of the matrix from bottom ; Update maxValue ; set maxArr ( i , j ) ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php $ N = 5 ; function findMaxValue ( $ mat ) { global $ N ; $ maxValue = PHP_INT_MIN ; $ maxArr [ $ N ] [ $ N ] = array ( ) ; $ maxArr [ $ N - 1 ] [ $ N - 1 ] = $ mat [ $ N - 1 ] [ $ N - 1 ] ; $ maxv = $ mat [ $ N - 1 ] [ $ N - 1 ] ; for ( $ j = $ N - 2 ; $ j >= 0 ; $ j -- ) { if ( $ mat [ $ N - 1 ] [ $ j ] > $ maxv ) $ maxv = $ mat [ $ N - 1 ] [ $ j ] ; $ maxArr [ $ N - 1 ] [ $ j ] = $ maxv ; } $ maxv = $ mat [ $ N - 1 ] [ $ N - 1 ] ; for ( $ i = $ N - 2 ; $ i >= 0 ; $ i -- ) { if ( $ mat [ $ i ] [ $ N - 1 ] > $ maxv ) $ maxv = $ mat [ $ i ] [ $ N - 1 ] ; $ maxArr [ $ i ] [ $ N - 1 ] = $ maxv ; } for ( $ i = $ N - 2 ; $ i >= 0 ; $ i -- ) { for ( $ j = $ N - 2 ; $ j >= 0 ; $ j -- ) { if ( $ maxArr [ $ i + 1 ] [ $ j + 1 ] - $ mat [ $ i ] [ $ j ] > $ maxValue ) $ maxValue = $ maxArr [ $ i + 1 ] [ $ j + 1 ] - $ mat [ $ i ] [ $ j ] ; $ maxArr [ $ i ] [ $ j ] = max ( $ mat [ $ i ] [ $ j ] , max ( $ maxArr [ $ i ] [ $ j + 1 ] , $ maxArr [ $ i + 1 ] [ $ j ] ) ) ; } } return $ maxValue ; } $ mat = array ( array ( 1 , 2 , -1 , -4 , -20 ) , array ( -8 , -3 , 4 , 2 , 1 ) , array ( 3 , 8 , 6 , 1 , 3 ) , array ( -4 , -1 , 1 , 7 , -6 ) , array ( 0 , -4 , 10 , -5 , 1 ) ) ; echo \\\" Maximum ▁ Value ▁ is ▁ \\\" . findMaxValue ( $ mat ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Cutting a Rod | DP | A Dynamic Programming solution for Rod cutting problem ; A utility function to get the maximum of two integers ; Returns the best obtainable price for a rod of length n and price [ ] as prices of different pieces ; Build the table val [ ] in bottom up manner and return the last entry from the table ; Driver program to test above functions\\\"\\nSolution in C:\",\"targets\":\"#include \\n#include \\nint max ( int a , int b ) { return ( a > b ) ? a : b ; } int cutRod ( int price [ ] , int n ) { int val [ n + 1 ] ; val [ 0 ] = 0 ; int i , j ; for ( i = 1 ; i <= n ; i ++ ) { int max_val = INT_MIN ; for ( j = 0 ; j < i ; j ++ ) max_val = max ( max_val , price [ j ] + val [ i - j - 1 ] ) ; val [ i ] = max_val ; } return val [ n ] ; } int main ( ) { int arr [ ] = { 1 , 5 , 8 , 9 , 10 , 17 , 17 , 20 } ; int size = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; printf ( \\\" Maximum ▁ Obtainable ▁ Value ▁ is ▁ % d \\\" , cutRod ( arr , size ) ) ; getchar ( ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Check whether the given number is Wagstaff prime or not | CPP program to check if a number is Wagstaff prime or not ; Function to check if a number is prime or not ; Corner cases ; This is checked so that we can skip middle five numbers in below loop ; Utility function to check power of two ; Driver Program ; Check if number is prime and of the form ( 2 ^ q + 1 ) \\/ 3\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; bool isPrime ( 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 ; } bool isPowerOfTwo ( int n ) { return ( n && ! ( n & ( n - 1 ) ) ) ; } int main ( ) { int n = 43 ; if ( isPrime ( n ) && ( isPowerOfTwo ( n * 3 - 1 ) ) ) { cout << \\\" YES \\n \\\" ; } else { cout << \\\" NO \\n \\\" ; } return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Lexicographically largest string possible by reversing substrings having even number of 1 s | Java program for the above approach ; Function to find the lexicographically maximum string by reversing substrings having even numbers of 1 s ; Store size of string ; Traverse the string ; Count the number of 1 s ; Stores the starting index ; Stores the end index ; Increment count , when 1 is encountered ; Traverse the remaining string ; Reverse the string from starting and end index ; Printing the string ; Driver Code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { static void lexicographicallyMax ( String s ) { int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int count = 0 ; int beg = i ; int end = i ; if ( s . charAt ( i ) == '1' ) count ++ ; for ( int j = i + 1 ; j < n ; j ++ ) { if ( s . charAt ( j ) == '1' ) count ++ ; if ( count % 2 == 0 && count != 0 ) { end = j ; break ; } } s = reverse ( s , beg , end + 1 ) ; } System . out . println ( s ) ; } static String reverse ( String s , int beg , int end ) { StringBuilder x = new StringBuilder ( \\\" \\\" ) ; for ( int i = 0 ; i < beg ; i ++ ) x . append ( s . charAt ( i ) ) ; for ( int i = end - 1 ; i >= beg ; i -- ) x . append ( s . charAt ( i ) ) ; for ( int i = end ; i < s . length ( ) ; i ++ ) x . append ( s . charAt ( i ) ) ; return x . toString ( ) ; } public static void main ( String args [ ] ) { String S = \\\"0101\\\" ; lexicographicallyMax ( S ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Finding n | PHP program to find n - th number with prime digits 2 , 3 and 7 ; remainder for check element position ; if number is 1 st position in tree ; if number is 2 nd position in tree ; if number is 3 rd position in tree ; if number is 4 th position in tree ; Driver code\\\"\\nSolution in php:\",\"targets\":\"< ? php function nthprimedigitsnumber ( $ number ) { $ num = \\\" \\\" ; while ( $ number > 0 ) { $ rem = $ number % 4 ; switch ( $ rem ) { case 1 : $ num . = '2' ; break ; case 2 : $ num . = '3' ; break ; case 3 : $ num . = '5' ; break ; case 0 : $ num . = '7' ; break ; } if ( $ number % 4 == 0 ) $ number -- ; $ number = ( int ) ( $ number \\/ 4 ) ; } return strrev ( $ num ) ; } $ number = 21 ; print ( nthprimedigitsnumber ( 10 ) . \\\" \\n \\\" ) ; print ( nthprimedigitsnumber ( $ number ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Find the player to be able to replace the last element that can be replaced by its divisors | C ++ program for the above approach ; Function to find the winner of the game played based on given conditions ; A wins if size of array is odd ; Otherwise , B wins ; Driver Code ; Input array ; Size of the array\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; void winner ( int arr [ ] , int N ) { if ( N % 2 == 1 ) { cout << \\\" A \\\" ; } else { cout << \\\" B \\\" ; } } int main ( ) { int arr [ ] = { 24 , 45 , 45 , 24 } ; int N = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; winner ( arr , N ) ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Sequence with sum K and minimum sum of absolute differences between consecutive elements | Java implementation of the approach ; Function to return the minimized sum ; If k is divisible by n then the answer will be 0 ; Else the answer will be 1 ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"import java . io . * ; class GFG { static int minimum_sum ( int n , int k ) { if ( k % n == 0 ) return 0 ; return 1 ; } public static void main ( String [ ] args ) { int n = 3 , k = 56 ; System . out . println ( minimum_sum ( n , k ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Reverse words in a given string | Java code to reverse a string ; Reverse the string ; Check if number of words is even ; Find the middle word ; Starting from the middle start swapping words at jth position and l - 1 - j position ; Check if number of words is odd ; Find the middle word ; Starting from the middle start swapping the words at jth position and l - 1 - j position ; Return the reversed sentence ; Driver Code\\\"\\nSolution in Java:\",\"targets\":\"class GFG { public static String [ ] RevString ( String [ ] s , int l ) { if ( l % 2 == 0 ) { int j = l \\/ 2 ; while ( j <= l - 1 ) { String temp ; temp = s [ l - j - 1 ] ; s [ l - j - 1 ] = s [ j ] ; s [ j ] = temp ; j += 1 ; } } else { int j = ( l \\/ 2 ) + 1 ; while ( j <= l - 1 ) { String temp ; temp = s [ l - j - 1 ] ; s [ l - j - 1 ] = s [ j ] ; s [ j ] = temp ; j += 1 ; } } return s ; } public static void main ( String [ ] args ) { String s = \\\" getting ▁ good ▁ at ▁ coding ▁ \\\" + \\\" needs ▁ a ▁ lot ▁ of ▁ practice \\\" ; String [ ] words = s . split ( \\\" \\\\\\\\ s \\\" ) ; words = RevString ( words , words . length ) ; s = String . join ( \\\" ▁ \\\" , words ) ; System . out . println ( s ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Find Union and Intersection of two unsorted arrays | Java code to find intersection when elements may not be distinct ; Function to find intersection ; when both are equal ; Driver Code ; sort ; Function call\\\"\\nSolution in Java:\",\"targets\":\"import java . io . * ; import java . util . Arrays ; class GFG { static void intersection ( int a [ ] , int b [ ] , int n , int m ) { int i = 0 , j = 0 ; while ( i < n && j < m ) { if ( a [ i ] > b [ j ] ) { j ++ ; } else if ( b [ j ] > a [ i ] ) { i ++ ; } else { System . out . print ( a [ i ] + \\\" ▁ \\\" ) ; i ++ ; j ++ ; } } } public static void main ( String [ ] args ) { int a [ ] = { 1 , 3 , 2 , 3 , 4 , 5 , 5 , 6 } ; int b [ ] = { 3 , 3 , 5 } ; int n = a . length ; int m = b . length ; Arrays . sort ( a ) ; Arrays . sort ( b ) ; intersection ( a , b , n , m ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Count Distinct Non | An efficient C program to find different ( x , y ) pairs that satisfy x * x + y * y < n . ; This function counts number of pairs ( x , y ) that satisfy the inequality x * x + y * y < n . ; Find the count of different y values for x = 0. ; One by one increase value of x , and find yCount for current x . If yCount becomes 0 , then we have reached maximum possible value of x . ; Add yCount ( count of different possible values of y for current x ) to result ; Increment x ; Update yCount for current x . Keep reducing yCount while the inequality is not satisfied . ; Driver program to test above function\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int countSolutions ( int n ) { int x = 0 , yCount , res = 0 ; for ( yCount = 0 ; yCount * yCount < n ; yCount ++ ) ; while ( yCount != 0 ) { res += yCount ; x ++ ; while ( yCount != 0 && ( x * x + ( yCount - 1 ) * ( yCount - 1 ) >= n ) ) yCount -- ; } return res ; } int main ( ) { cout << \\\" Total ▁ Number ▁ of ▁ distinct ▁ Non - Negative ▁ pairs ▁ is ▁ \\\" << countSolutions ( 6 ) << endl ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Number of ways of cutting a Matrix such that atleast one cell is filled in each part | CPP implementation to find the number of ways to cut the matrix into the K parts such that each part have atleast one filled cell ; Function to find the number of ways to cut the matrix into the K parts such that each part have atleast one filled cell ; Loop to find prefix sum of the given matrix ; dp ( r , c , 1 ) = 1 if preSum [ r ] else 0 ; Loop to iterate over the dp table of the given matrix ; Check if can cut horizontally at r1 , at least one apple in matrix ( r , c ) -> r1 , C - 1 ; Check if we can cut vertically at c1 , at least one apple in matrix ( r , c ) -> R - 1 , c1 ; Driver code ; Function Call\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int ways ( vector < vector < int > > & arr , int K ) { int R = arr . size ( ) ; int C = arr [ 0 ] . size ( ) ; int preSum [ R ] [ C ] ; for ( int r = R - 1 ; r >= 0 ; r -- ) { for ( int c = C - 1 ; c >= 0 ; c -- ) { preSum [ r ] = arr [ r ] ; if ( r + 1 < R ) preSum [ r ] += preSum [ r + 1 ] ; if ( c + 1 < C ) preSum [ r ] += preSum [ r ] ; if ( r + 1 < R && c + 1 < C ) preSum [ r ] -= preSum [ r + 1 ] ; } } int dp [ K + 1 ] [ R ] [ C ] ; for ( int k = 1 ; k <= K ; k ++ ) { for ( int r = R - 1 ; r >= 0 ; r -- ) { for ( int c = C - 1 ; c >= 0 ; c -- ) { if ( k == 1 ) { dp [ k ] [ r ] = ( preSum [ r ] > 0 ) ? 1 : 0 ; } else { dp [ k ] [ r ] = 0 ; for ( int r1 = r + 1 ; r1 < R ; r1 ++ ) { if ( preSum [ r ] - preSum [ r1 ] > 0 ) dp [ k ] [ r ] += dp [ k - 1 ] [ r1 ] ; } for ( int c1 = c + 1 ; c1 < C ; c1 ++ ) { if ( preSum [ r ] - preSum [ r ] [ c1 ] > 0 ) dp [ k ] [ r ] += dp [ k - 1 ] [ r ] [ c1 ] ; } } } } } return dp [ K ] [ 0 ] [ 0 ] ; } int main ( ) { vector < vector < int > > arr = { { 1 , 0 , 0 } , { 1 , 1 , 1 } , { 0 , 0 , 0 } } ; int k = 3 ; cout << ways ( arr , k ) << endl ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Maximum determinant of a matrix with every values either 0 or n | Function for maximum determinant ; Function to print resulatant matrix ; three position where 0 appears ; position where n appears ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function maxDet ( $ n ) { return ( 2 * $ n * $ n * $ n ) ; } function resMatrix ( $ n ) { for ( $ i = 0 ; $ i < 3 ; $ i ++ ) { for ( $ j = 0 ; $ j < 3 ; $ j ++ ) { if ( $ i == 0 && $ j == 2 ) echo \\\"0 ▁ \\\" ; else if ( $ i == 1 && $ j == 0 ) echo \\\"0 ▁ \\\" ; else if ( $ i == 2 && $ j == 1 ) echo \\\"0 ▁ \\\" ; else echo $ n , \\\" ▁ \\\" ; } echo \\\" \\n \\\" ; } } $ n = 15 ; echo \\\" Maximum ▁ Determinant ▁ = ▁ \\\" , maxDet ( $ n ) ; echo \\\" Resultant Matrix : \\\" resMatrix ( $ n ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Generate an array of minimum sum whose XOR of same | C # program to implement the above approach ; Function to generate an array whose XOR with same - indexed elements of the given array is always a prime ; Traverse the array ; If current array element is 2 ; Print its XOR with 3 ; Otherwise ; Print its XOR with 2 ; Driver code ; Given array ; Size of the array ; Prints the required array\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { private static void minXOR ( int [ ] Arr , int N ) { for ( int i = 0 ; i < N ; i ++ ) { if ( Arr [ i ] == 2 ) { Console . Write ( ( Arr [ i ] ^ 3 ) + \\\" ▁ \\\" ) ; } else { Console . Write ( ( Arr [ i ] ^ 2 ) + \\\" ▁ \\\" ) ; } } } public static void Main ( ) { int [ ] Arr = { 5 , 4 , 7 , 6 } ; int N = Arr . Length ; minXOR ( Arr , N ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Pascal 's Triangle | A O ( n ^ 2 ) time and O ( n ^ 2 ) extra space method for Pascal 's Triangle ; An auxiliary array to store generated pscal triangle values ; Iterate through every line and print integer ( s ) in it ; Every line has number of integers equal to line number ; First and last values in every row are 1 ; Other values are sum of values just above and left of above ; Driver code\\\"\\nSolution in C:\",\"targets\":\"void printPascal ( int n ) { int arr [ n ] [ n ] ; for ( int line = 0 ; line < n ; line ++ ) { for ( int i = 0 ; i <= line ; i ++ ) { if ( line == i i == 0 ) arr [ line ] [ i ] = 1 ; else arr [ line ] [ i ] = arr [ line - 1 ] [ i - 1 ] + arr [ line - 1 ] [ i ] ; printf ( \\\" % d ▁ \\\" , arr [ line ] [ i ] ) ; } printf ( \\\" \\n \\\" ) ; } } int main ( ) { int n = 5 ; printPascal ( n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Rearrange a given linked list in | Javascript code to rearrange linked list in place ; function for rearranging a linked list with high and low value . ; Base case . ; two pointer variable . ; swap function for swapping data . ; swap function for swapping data . ; function to insert a Node in the linked list at the beginning . ; function to display Node of linked list . ; Let create a linked list . 9 . 6 . 8 . 3 . 7\\\"\\nHow can the above be solved in JS?\",\"targets\":\"class Node { constructor ( ) { this . data ; this . next = null ; } } function rearrange ( head ) { if ( head == null ) return null ; let prev = head , curr = head . next ; while ( curr != null ) { if ( prev . data > curr . data ) { let t = prev . data ; prev . data = curr . data ; curr . data = t ; } if ( curr . next != null && curr . next . data > curr . data ) { let t = curr . next . data ; curr . next . data = curr . data ; curr . data = t ; } prev = curr . next ; if ( curr . next == null ) break ; curr = curr . next . next ; } return head ; } function push ( head , k ) { let tem = new Node ( ) ; tem . data = k ; tem . next = head ; head = tem ; return head ; } function display ( head ) { let curr = head ; while ( curr != null ) { document . write ( curr . data + \\\" \\\" ) ; curr = curr . next ; } } let head = null ; head = push ( head , 7 ) ; head = push ( head , 3 ) ; head = push ( head , 8 ) ; head = push ( head , 6 ) ; head = push ( head , 9 ) ; head = rearrange ( head ) ; display ( head ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Equal Sum and XOR | function to count number of values less than equal to n that satisfy the given condition ; unset_bits keeps track of count of un - set bits in binary representation of n ; Return 2 ^ unset_bits ; Driver code\\\"\\nSolution in Python:\",\"targets\":\"def countValues ( n ) :\\n\\tunset_bits = 0\\n\\twhile ( n ) :\\n\\t\\tif n & 1 == 0 :\\n\\t\\t\\tunset_bits += 1\\n\\t\\tn = n >> 1\\n\\treturn 1 << unset_bits\\nif __name__ == ' _ _ main _ _ ' :\\n\\tn = 12\\n\\tprint ( countValues ( n ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Find the winner of a game of donating i candies in every i | Function to find the winning player in a game of donating i candies to opponent in i - th move ; Steps in which number of candies of player A finishes ; Steps in which number of candies of player B finishes ; If A 's candies finishes first ; Otherwise ; Candies possessed by player A ; Candies possessed by player B\\\"\\nSolution in Javascript:\",\"targets\":\"function stepscount ( a , b ) { let chanceA = 2 * a - 1 ; ; let chanceB = 2 * b ; if ( chanceA < chanceB ) { document . write ( \\\" \\\" ) ; } else if ( chanceB < chanceA ) { document . write ( \\\" \\\" ) ; } return 0 ; } let A = 2 ; let B = 3 ; stepscount ( A , B ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Palindromic divisors of a number | C ++ program to find all the palindromic divisors of a number ; Function to check is num is palindromic or not ; Convert n to string str ; Starting and ending index of string str ; If char at s and e are not equals then return false ; Function to find palindromic divisors ; To sore the palindromic divisors of number n ; If n is divisible by i ; Check if number is a perfect square ; Check divisor is palindromic , then store it ; Check if divisors are palindrome ; Check if n \\/ divisors is palindromic or not ; Print all palindromic divisors in sorted order ; Driver code ; Function call to find all palindromic divisors\\\"\\nSolution in C++:\",\"targets\":\"#include \\\" bits \\/ stdc + + . h \\\"\\nusing namespace std ; bool isPalindrome ( int n ) { string str = to_string ( n ) ; int s = 0 , e = str . length ( ) - 1 ; while ( s < e ) { if ( str [ s ] != str [ e ] ) { return false ; } s ++ ; e -- ; } return true ; } void palindromicDivisors ( int n ) { vector < int > PalindromDivisors ; for ( int i = 1 ; i <= sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( n \\/ i == i ) { if ( isPalindrome ( i ) ) { PalindromDivisors . push_back ( i ) ; } } else { if ( isPalindrome ( i ) ) { PalindromDivisors . push_back ( i ) ; } if ( isPalindrome ( n \\/ i ) ) { PalindromDivisors . push_back ( n \\/ i ) ; } } } } sort ( PalindromDivisors . begin ( ) , PalindromDivisors . end ( ) ) ; for ( int i = 0 ; i < PalindromDivisors . size ( ) ; i ++ ) { cout << PalindromDivisors [ i ] << \\\" ▁ \\\" ; } } int main ( ) { int n = 66 ; palindromicDivisors ( n ) ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Binomial Coefficient | DP | Function to find binomial coefficient ; Getting the modular inversion for all the numbers from 2 to r with respect to m here m = 1000000007 ; for 1 \\/ ( r ! ) part ; for ( n ) * ( n - 1 ) * ( n - 2 ) * ... * ( n - r + 1 ) part ; Driver code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def binomialCoeff ( n , r ) :\\n\\tif ( r > n ) :\\n\\t\\treturn 0\\n\\tm = 1000000007\\n\\tinv = [ 0 for i in range ( r + 1 ) ]\\n\\tinv [ 0 ] = 1\\n\\tif ( r + 1 >= 2 ) :\\n\\t\\tinv [ 1 ] = 1\\n\\tfor i in range ( 2 , r + 1 ) :\\n\\t\\tinv [ i ] = m - ( m \\/\\/ i ) * inv [ m % i ] % m\\n\\tans = 1\\n\\tfor i in range ( 2 , r + 1 ) :\\n\\t\\tans = ( ( ans % m ) * ( inv [ i ] % m ) ) % m\\n\\tfor i in range ( n , n - r , - 1 ) :\\n\\t\\tans = ( ( ans % m ) * ( i % m ) ) % m\\n\\treturn ans\\nn = 5\\nr = 2\\nprint ( \\\" Value ▁ of ▁ C ( \\\" , n , \\\" , ▁ \\\" , r , \\\" ) ▁ is ▁ \\\" , binomialCoeff ( n , r ) )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Average of even numbers till a given even number | Program to find average of even numbers till a given even number . ; Function to calculate the average of even numbers ; driver function\\\"\\nSolution in C:\",\"targets\":\"#include \\nint averageEven ( int n ) { if ( n % 2 != 0 ) { printf ( \\\" Invalid ▁ Input \\\" ) ; return -1 ; } return ( n + 2 ) \\/ 2 ; } int main ( ) { int n = 16 ; printf ( \\\" % d \\\" , averageEven ( n ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Efficiently merging two sorted arrays with O ( 1 ) extra space | ; Find maximum element of both array ; Increment one two avoid collision of 0 and maximum element of array in modulo operation ; Recover back original element to compare ; Update element by adding multiplication with new number ; Update element by adding multiplication with new number ; Process those elements which are left in array a ; Process those elements which are left in array a ; Finally update elements by dividing with maximum element ; Finally update elements by dividing with maximum element ; Driver code ; Length of a ; length of b ; Function Call\\\"\\nSolution in C#:\",\"targets\":\"using System ; public class GFG { static void mergeArray ( int [ ] a , int [ ] b , int n , int m ) { int mx = 0 ; for ( int I = 0 ; I < n ; I ++ ) { mx = Math . Max ( mx , a [ I ] ) ; } for ( int I = 0 ; I < m ; I ++ ) { mx = Math . Max ( mx , b [ I ] ) ; } mx ++ ; int i = 0 , j = 0 , k = 0 ; while ( i < n && j < m && k < ( n + m ) ) { int e1 = a [ i ] % mx ; int e2 = b [ j ] % mx ; if ( e1 <= e2 ) { if ( k < n ) a [ k ] += ( e1 * mx ) ; else b [ k - n ] += ( e1 * mx ) ; i ++ ; k ++ ; } else { if ( k < n ) a [ k ] += ( e2 * mx ) ; else b [ k - n ] += ( e2 * mx ) ; j ++ ; k ++ ; } } while ( i < n ) { int el = a [ i ] % mx ; if ( k < n ) a [ k ] += ( el * mx ) ; else b [ k - n ] += ( el * mx ) ; i ++ ; k ++ ; } while ( j < m ) { int el = b [ j ] % mx ; if ( k < n ) b [ k ] += ( el * mx ) ; else b [ k - n ] += ( el * mx ) ; j ++ ; k ++ ; } for ( int In = 0 ; In < n ; In ++ ) a [ In ] = a [ In ] \\/ mx ; for ( int In = 0 ; In < m ; In ++ ) b [ In ] = b [ In ] \\/ mx ; return ; } static public void Main ( ) { int [ ] a = { 3 , 5 , 6 , 8 , 12 } ; int [ ] b = { 1 , 4 , 9 , 13 } ; int n = a . Length ; int m = b . Length ; mergeArray ( a , b , n , m ) ; Console . Write ( \\\" First ▁ array ▁ : ▁ \\\" ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( a [ i ] + \\\" ▁ \\\" ) ; Console . WriteLine ( ) ; Console . Write ( \\\" Second ▁ array ▁ : ▁ \\\" ) ; for ( int i = 0 ; i < m ; i ++ ) Console . Write ( b [ i ] + \\\" ▁ \\\" ) ; Console . WriteLine ( ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Lynch | C implementation for the above approach ; Function to check the divisibility of the number by its digit . ; If the digit divides the number then return true else return false . ; Function to check if all digits of n divide it or not ; Taking the digit of the number into digit var . ; Function to check if N has all distinct digits ; Create an array of size 10 and initialize all elements as false . This array is used to check if a digit is already seen or not . ; Traverse through all digits of given number ; Find the last digit ; If digit is already seen , return false ; Mark this digit as seen ; Remove the last digit from number ; Function to check Lynch - Bell numbers ; Driver Code ; Given number N ; Function call\\\"\\nSolution in C:\",\"targets\":\"#include \\nint checkDivisibility ( int n , int digit ) { return ( digit != 0 && n % digit == 0 ) ; } int isAllDigitsDivide ( int n ) { int temp = n ; while ( temp > 0 ) { int digit = temp % 10 ; if ( ! ( checkDivisibility ( n , digit ) ) ) return 0 ; temp \\/= 10 ; } return 1 ; } int isAllDigitsDistinct ( int n ) { int arr [ 10 ] , i , digit ; for ( i = 0 ; i < 10 ; i ++ ) arr [ i ] = 0 ; while ( n > 0 ) { digit = n % 10 ; if ( arr [ digit ] ) return 0 ; arr [ digit ] = 1 ; n = n \\/ 10 ; } return 1 ; } int isLynchBell ( int n ) { return isAllDigitsDivide ( n ) && isAllDigitsDistinct ( n ) ; } int main ( ) { int N = 12 ; if ( isLynchBell ( N ) ) printf ( \\\" Yes \\\" ) ; else printf ( \\\" No \\\" ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Count of pairs from 1 to a and 1 to b whose sum is divisible by N | Function to find the distinct pairs from 1 - a & 1 - b such that their sum is divisible by n . ; Iterate over 1 to a to find distinct pairs ; For each integer from 1 to a b \\/ n integers exists such that pair \\/ sum is divisible by n ; If ( i % n + b % n ) >= n one more pair is possible ; Return answer ; Driver code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def findCountOfPairs ( a , b , n ) :\\n\\tans = 0\\n\\tfor i in range ( 1 , a + 1 ) :\\n\\t\\tans += b \\/\\/ n\\n\\t\\tans += 1 if ( i % n + b % n ) >= n else 0\\n\\treturn ans\\na = 5 ; b = 13 ; n = 3\\nprint ( findCountOfPairs ( a , b , n ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Sum of squares of all Subsets of given Array | C ++ implementation of the approach ; Function to return ( 2 ^ P % mod ) ; Function to return the sum of squares of subsets ; Sqauaring the elements and adding it to ans ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; const int mod = 1e9 + 7 ; long long power ( int p ) { long long res = 1 ; for ( int i = 1 ; i <= p ; ++ i ) { res *= 2 ; res %= mod ; } return res % mod ; } long long subset_square_sum ( vector < int > & A ) { int n = ( int ) A . size ( ) ; long long ans = 0 ; for ( int i : A ) { ans += ( 1LL * i * i ) % mod ; ans %= mod ; } return ( 1LL * ans * power ( n - 1 ) ) % mod ; } int main ( ) { vector < int > A = { 3 , 7 } ; cout << subset_square_sum ( A ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Maximize the median of the given array after adding K elements to the same array | PHP implementation of the approach Function to return the maximized median ; Sort the array ; If size is even ; If size is odd ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function getMaxMedian ( $ arr , $ n , $ k ) { $ size = $ n + $ k ; sort ( $ arr , $ n ) ; if ( $ size % 2 == 0 ) { $ median = ( float ) ( $ arr [ ( $ size \\/ 2 ) - 1 ] + $ arr [ $ size \\/ 2 ] ) \\/ 2 ; return $ median ; } $ median = $ arr [ $ size \\/ 2 ] ; return $ median ; } $ arr = array ( 3 , 2 , 3 , 4 , 2 ) ; $ n = sizeof ( $ arr ) ; $ k = 2 ; echo ( getMaxMedian ( $ arr , $ n , $ k ) ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Maximum possible prime divisors that can exist in numbers having exactly N divisors | Function to find the maximum possible prime divisors of a number can have with N divisors ; Number of time number divided by 2 ; Divide by other prime numbers ; If the last number of also prime then also include it ; Driver Code ; Function Call\\\"\\nSolution in Javascript:\",\"targets\":\"function findMaxPrimeDivisor ( n ) { let max_possible_prime = 0 ; while ( n % 2 == 0 ) { max_possible_prime ++ ; n = Math . floor ( n \\/ 2 ) ; } for ( let i = 3 ; i * i <= n ; i = i + 2 ) { while ( n % i == 0 ) { max_possible_prime ++ ; n = Math . floor ( n \\/ i ) ; } } if ( n > 2 ) { max_possible_prime ++ ; } document . write ( max_possible_prime + \\\" \\\" ) ; } let n = 4 ; findMaxPrimeDivisor ( n ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Program to check if a matrix is symmetric | Simple C # code for check a matrix is symmetric or not . ; Fills transpose of mat [ N ] [ N ] in tr [ N ] [ N ] ; Returns true if mat [ N ] [ N ] is symmetric , else false ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int MAX = 100 ; static void transpose ( int [ , ] mat , int [ , ] tr , int N ) { for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) tr [ i , j ] = mat [ j , i ] ; } static bool isSymmetric ( int [ , ] mat , int N ) { int [ , ] tr = new int [ N , MAX ] ; transpose ( mat , tr , N ) ; for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) if ( mat [ i , j ] != tr [ i , j ] ) return false ; return true ; } public static void Main ( ) { int [ , ] mat = { { 1 , 3 , 5 } , { 3 , 2 , 4 } , { 5 , 4 , 1 } } ; if ( isSymmetric ( mat , 3 ) ) Console . WriteLine ( \\\" Yes \\\" ) ; else Console . WriteLine ( \\\" No \\\" ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Polygon with maximum sides that can be inscribed in an N | Function to find the maximum sided polygon that can be inscribed ; Base Case ; Return n \\/ 2 if n is even Otherwise , return - 1 ; Given N ; Function Call\\\"\\nSolution in Javascript:\",\"targets\":\"function MaximumSides ( n ) { if ( n < 4 ) return - 1 ; return n % 2 == 0 ? n \\/ 2 : - 1 ; } let N = 8 ; document . write ( MaximumSides ( N ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Maximize count of Decreasing Subsequences from the given Array | C # program for rearrange array to generate maximum decreasing subsequences ; Function to count maximum subsequence ; Stores the frequency of array elements ; Stores maximum frequency ; Update frequency of A [ i ] ; Update maximum subsequences ; Print the result ; Driver Code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; using System . Collections . Generic ; class GFG { public static void Maximum_subsequence ( int [ ] A , int N ) { Dictionary < int , int > frequency = new Dictionary < int , int > ( ) ; int max_freq = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( frequency . ContainsKey ( A [ i ] ) ) { frequency [ A [ i ] ] = frequency [ A [ i ] ] + 1 ; } else { frequency . Add ( A [ i ] , 1 ) ; } } foreach ( KeyValuePair < int , int > it in frequency ) { if ( ( int ) it . Value > max_freq ) { max_freq = ( int ) it . Value ; } } Console . WriteLine ( max_freq ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 2 , 6 , 5 , 2 , 4 , 5 , 2 } ; int N = arr . Length ; Maximum_subsequence ( arr , N ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Count of numbers in range [ L , R ] having sum of digits of its square equal to square of sum of digits | Function to check if the number is valid ; Sum of digits of num ; Squared number ; Sum of digits of ( num * num ) ; Function to convert a string to an integer ; Function to generate all possible strings of length len ; Desired string ; Take only valid numbers ; Recurse for all possible digits ; Function to calculate unique numbers in range [ L , R ] ; Initialize a variable to store the answer ; Calculate the maximum possible length ; Set to store distinct valid numbers ; Generate all possible strings of length i ; Iterate the set to get the count of valid numbers in the range [ L , R ] ; Driver Code\\\"\\nSolution in Javascript:\",\"targets\":\"function check ( num ) { let sm = 0 ; let num2 = num * num ; while ( num ) { sm += num % 10 ; num = Math . floor ( num \\/ 10 ) ; } let sm2 = 0 ; while ( num2 ) { sm2 += num2 % 10 ; num2 = Math . floor ( num2 \\/ 10 ) ; } return sm * sm == sm2 ; } function convert ( s ) { let val = 0 ; s = s . split ( \\\" \\\" ) . reverse ( ) . join ( \\\" \\\" ) ; let cur = 1 ; for ( let i = 0 ; i < s . length ; i ++ ) { val += ( s [ i ] . charCodeAt ( 0 ) - \\\" \\\" . charCodeAt ( 0 ) ) * cur ; cur *= 10 ; } return val ; } function generate ( s , len , uniq ) { if ( s . length == len ) { if ( check ( convert ( s ) ) ) { uniq . add ( convert ( s ) ) ; } return ; } for ( let i = 0 ; i <= 3 ; i ++ ) { generate ( s + String . fromCharCode ( i + \\\" \\\" . charCodeAt ( 0 ) ) , len , uniq ) ; } } function totalNumbers ( L , R ) { let ans = 0 ; let max_len = Math . log10 ( R ) + 1 ; let uniq = new Set ( ) ; for ( let i = 1 ; i <= max_len ; i ++ ) { generate ( \\\" \\\" , i , uniq ) ; } for ( let x of uniq ) { if ( x >= L && x <= R ) { ans ++ ; } } return ans ; } let L = 22 , R = 22 ; document . write ( totalNumbers ( L , R ) ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"Maximum difference between two elements such that larger element appears after the smaller number | ; The function assumes that there are at least two elements in array . The function returns a negative value if the array is sorted in decreasing order . Returns 0 if elements are equal ; Driver program to test above function ; Function calling\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint maxDiff ( int arr [ ] , int arr_size ) { int max_diff = arr [ 1 ] - arr [ 0 ] ; int i , j ; for ( i = 0 ; i < arr_size ; i ++ ) { for ( j = i + 1 ; j < arr_size ; j ++ ) { if ( arr [ j ] - arr [ i ] > max_diff ) max_diff = arr [ j ] - arr [ i ] ; } } return max_diff ; } int main ( ) { int arr [ ] = { 1 , 2 , 90 , 10 , 110 } ; printf ( \\\" Maximum ▁ difference ▁ is ▁ % d \\\" , maxDiff ( arr , 5 ) ) ; getchar ( ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"Sum of divisors of factorial of a number | C program to find sum of proper divisor of factorial of a number ; function to calculate factorial ; function to calculate sum of divisor ; Returns sum of divisors of n ! ; driver program\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint fact ( int n ) { if ( n == 0 ) return 1 ; return n * fact ( n - 1 ) ; } int div ( int x ) { int ans = 0 ; for ( int i = 1 ; i <= x ; i ++ ) if ( x % i == 0 ) ans += i ; return ans ; } int sumFactDiv ( int n ) { return div ( fact ( n ) ) ; } int main ( ) { int n = 4 ; printf ( \\\" % d \\\" , sumFactDiv ( n ) ) ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Area of a square inscribed in a circle which is inscribed in an equilateral triangle | Function to find the area of the square ; a cannot be negative ; area of the square ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function area ( $ a ) { if ( $ a < 0 ) return -1 ; $ area = sqrt ( $ a ) \\/ 6 ; return $ area ; } $ a = 10 ; echo area ( $ a ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Check if a number starts with another number or not | C ++ program for the above approach ; Function to check if B is a prefix of A or not ; Convert numbers into strings ; Check if s2 is a prefix of s1 or not using starts_with ( ) function ; If result is true , print \\\" Yes \\\" ; Driver Code ; Given numbers ; Function Call\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\n#include \\nusing namespace std ; void checkprefix ( int A , int B ) { string s1 = to_string ( A ) ; string s2 = to_string ( B ) ; bool result ; result = boost :: algorithm :: starts_with ( s1 , s2 ) ; if ( result ) { cout << \\\" Yes \\\" ; } else { cout << \\\" No \\\" ; } } int main ( ) { int A = 12345 , B = 12 ; checkprefix ( A , B ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Check if given Sudoku solution is valid or not | Function to check if all elements of the board [ ] [ ] array store value in the range [ 1 , 9 ] ; Traverse board [ ] [ ] array ; Check if board [ i ] [ j ] lies in the range ; Function to check if the solution of sudoku puzzle is valid or not ; Check if all elements of board [ ] [ ] stores value in the range [ 1 , 9 ] ; Stores unique value from 1 to N ; Traverse each row of the given array ; Initialize unique [ ] array to false ; Traverse each column of current row ; Stores the value of board [ i ] [ j ] ; Check if current row stores duplicate value ; Traverse each column of the given array ; Initialize unique [ ] array to false ; Traverse each row of current column ; Stores the value of board [ j ] [ i ] ; Check if current column stores duplicate value ; Traverse each block of size 3 * 3 in board [ ] [ ] array ; j stores first column of each 3 * 3 block ; Initialize unique [ ] array to false ; Traverse current block ; Stores row number of current block ; Stores column number of current block ; Stores the value of board [ X ] [ Y ] ; Check if current block stores duplicate value ; If all conditions satisfied ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def isinRange ( board ) :\\n\\tN = 9\\n\\tfor i in range ( 0 , N ) :\\n\\t\\tfor j in range ( 0 , N ) :\\n\\t\\tif ( ( board [ i ] [ j ] <= 0 ) or ( board [ i ] [ j ] > 9 ) ) :\\n\\t\\t\\treturn False\\n\\treturn True\\ndef isValidSudoku ( board ) :\\n\\tN = 9\\n\\tif ( isinRange ( board ) == False ) :\\n\\t\\treturn False\\n\\tunique = [ False ] * ( N + 1 )\\n\\tfor i in range ( 0 , N ) :\\n\\t\\tfor m in range ( 0 , N + 1 ) :\\n\\t\\tunique [ m ] = False\\n\\t\\tfor j in range ( 0 , N ) :\\n\\t\\tZ = board [ i ] [ j ]\\n\\t\\tif ( unique [ Z ] == True ) :\\n\\t\\t\\treturn False\\n\\t\\tunique [ Z ] = True\\n\\tfor i in range ( 0 , N ) :\\n\\t\\tfor m in range ( 0 , N + 1 ) :\\n\\t\\tunique [ m ] = False\\n\\t\\tfor j in range ( 0 , N ) :\\n\\t\\tZ = board [ j ] [ i ]\\n\\t\\tif ( unique [ Z ] == True ) :\\n\\t\\t\\treturn False\\n\\t\\tunique [ Z ] = True\\n\\tfor i in range ( 0 , N - 2 , 3 ) :\\n\\t\\tfor j in range ( 0 , N - 2 , 3 ) :\\n\\t\\tfor m in range ( 0 , N + 1 ) :\\n\\t\\t\\tunique [ m ] = False\\n\\t\\tfor k in range ( 0 , 3 ) :\\n\\t\\t\\tfor l in range ( 0 , 3 ) :\\n\\t\\t\\tX = i + k\\n\\t\\t\\tY = j + l\\n\\t\\t\\tZ = board [ X ] [ Y ]\\n\\t\\t\\tif ( unique [ Z ] == True ) :\\n\\t\\t\\t\\treturn False\\n\\t\\t\\tunique [ Z ] = True\\n\\treturn True\\nif __name__ == ' _ _ main _ _ ' :\\n\\tboard = [ [ 7 , 9 , 2 , 1 , 5 , 4 , 3 , 8 , 6 ] , [ 6 , 4 , 3 , 8 , 2 , 7 , 1 , 5 , 9 ] , [ 8 , 5 , 1 , 3 , 9 , 6 , 7 , 2 , 4 ] , [ 2 , 6 , 5 , 9 , 7 , 3 , 8 , 4 , 1 ] , [ 4 , 8 , 9 , 5 , 6 , 1 , 2 , 7 , 3 ] , [ 3 , 1 , 7 , 4 , 8 , 2 , 9 , 6 , 5 ] , [ 1 , 3 , 6 , 7 , 4 , 8 , 5 , 9 , 2 ] , [ 9 , 7 , 4 , 2 , 1 , 5 , 6 , 3 , 8 ] , [ 5 , 2 , 8 , 6 , 3 , 9 , 4 , 1 , 7 ] ]\\n\\tif ( isValidSudoku ( board ) ) :\\n\\t\\tprint ( \\\" Valid \\\" )\\n\\telse :\\n\\t\\tprint ( \\\" Not ▁ Valid \\\" )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Count of permutations such that sum of K numbers from given range is even | C # program for the above approach ; Function to return the number of all permutations such that sum of K numbers in range is even ; Find total count of even and odd number in given range ; Iterate loop k times and update even_sum & odd_sum using previous values ; Update the prev_even and odd_sum ; Even sum ; Odd sum ; Return even_sum ; Driver Code ; Given ranges ; Length of permutation ; Function call\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { public static void countEvenSum ( int low , int high , int k ) { int even_count = high \\/ 2 - ( low - 1 ) \\/ 2 ; int odd_count = ( high + 1 ) \\/ 2 - low \\/ 2 ; long even_sum = 1 ; long odd_sum = 0 ; for ( int i = 0 ; i < k ; i ++ ) { long prev_even = even_sum ; long prev_odd = odd_sum ; even_sum = ( prev_even * even_count ) + ( prev_odd * odd_count ) ; odd_sum = ( prev_even * odd_count ) + ( prev_odd * even_count ) ; } Console . WriteLine ( even_sum ) ; } public static void Main ( String [ ] args ) { int low = 4 ; int high = 5 ; int K = 3 ; countEvenSum ( low , high , K ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"Multiply two integers without using multiplication , division and bitwise operators , and no loops | ; function to multiply two numbers x and y ; 0 multiplied with anything gives 0 ; Add x one by one ; the case where y is negative ; Driver Code\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint multiply ( int x , int y ) { if ( y == 0 ) return 0 ; if ( y > 0 ) return ( x + multiply ( x , y - 1 ) ) ; if ( y < 0 ) return - multiply ( x , - y ) ; } int main ( ) { printf ( \\\" % d \\\" , multiply ( 5 , -11 ) ) ; getchar ( ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Space and time efficient Binomial Coefficient | Program to calculate C ( n , k ) ; Returns value of Binomial Coefficient C ( n , k ) ; Since C ( n , k ) = C ( n , n - k ) ; Calculate value of [ n * ( n - 1 ) * -- - * ( n - k + 1 ) ] \\/ [ k * ( k - 1 ) * -- -- * 1 ] ; Driver program to test above function\\\"\\nSolution in C:\",\"targets\":\"#include \\nint binomialCoeff ( int n , int k ) { int res = 1 ; if ( k > n - k ) k = n - k ; for ( int i = 0 ; i < k ; ++ i ) { res *= ( n - i ) ; res \\/= ( i + 1 ) ; } return res ; } int main ( ) { int n = 8 , k = 2 ; printf ( \\\" Value ▁ of ▁ C ( % d , ▁ % d ) ▁ is ▁ % d ▁ \\\" , n , k , binomialCoeff ( n , k ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Primality Test | Set 5 ( Using Lucas | Function to check whether ( 2 ^ p - 1 ) is prime or not . ; generate the number ; First number of the series ; Generate the rest ( p - 2 ) terms of the series . ; now if the ( p - 1 ) th term is 0 return true else false . ; Check whether 2 ^ p - 1 is prime or not .\\\"\\nSolution in Javascript:\",\"targets\":\"function isPrime ( p ) { let checkNumber = Math . pow ( 2 , p ) - 1 ; let nextval = 4 % checkNumber ; for ( let i = 1 ; i < p - 1 ; i ++ ) nextval = ( nextval * nextval - 2 ) % checkNumber ; return ( nextval == 0 ) ; } let p = 7 ; let checkNumber = Math . pow ( 2 , p ) - 1 ; if ( isPrime ( p ) ) document . write ( checkNumber + \\\" \\\" ) ; else document . write ( checkNumber + \\\" \\\" ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Maximum sum and product of the M consecutive digits in a number | Python implementation of above approach ; Function to find the maximum product ; Driver code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"import sys\\ndef maxProductSum ( string , m ) :\\n\\tn = len ( string )\\n\\tmaxProd , maxSum = ( - ( sys . maxsize ) - 1 , - ( sys . maxsize ) - 1 )\\n\\tfor i in range ( n - m + 1 ) :\\n\\t\\tproduct , sum = 1 , 0\\n\\t\\tfor j in range ( i , m + i ) :\\n\\t\\t\\tproduct = product * ( ord ( string [ j ] ) - ord ( '0' ) )\\n\\t\\t\\tsum = sum + ( ord ( string [ j ] ) - ord ( '0' ) )\\n\\t\\tmaxProd = max ( maxProd , product )\\n\\t\\tmaxSum = max ( maxSum , sum )\\n\\tprint ( \\\" Maximum ▁ Product ▁ = \\\" , maxProd )\\n\\tprint ( \\\" Maximum ▁ sum ▁ = \\\" , maxSum )\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tstring = \\\"3605356297\\\"\\n\\tm = 3\\n\\tmaxProductSum ( string , m )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Paper Cut into Minimum Number of Squares | Set 2 | C # program to find minimum number of squares to cut a paper using Dynamic Programming ; Returns min number of squares needed ; Initializing max values to vertical_min and horizontal_min ; N = 11 & M = 13 is a special case ; If the given rectangle is already a square ; If the answer for the given rectangle is previously calculated return that answer ; The rectangle is cut horizontally and vertically into two parts and the cut with minimum value is found for every recursive call . ; Calculating the minimum answer for the rectangles with width equal to n and length less than m for finding the cut point for the minimum answer ; Calculating the minimum answer for the rectangles with width less than n and length equal to m for finding the cut point for the minimum answer ; Minimum of the vertical cut or horizontal cut to form a square is the answer ; Driver code ; Function call\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int [ , ] dp = new int [ 300 , 300 ] ; static int minimumSquare ( int m , int n ) { int vertical_min = int . MaxValue ; int horizontal_min = int . MaxValue ; if ( n == 13 && m == 11 ) return 6 ; if ( m == 13 && n == 11 ) return 6 ; if ( m == n ) return 1 ; if ( dp [ m , n ] != 0 ) return dp [ m , n ] ; for ( int i = 1 ; i <= m \\/ 2 ; i ++ ) { horizontal_min = Math . Min ( minimumSquare ( i , n ) + minimumSquare ( m - i , n ) , horizontal_min ) ; } for ( int j = 1 ; j <= n \\/ 2 ; j ++ ) { vertical_min = Math . Min ( minimumSquare ( m , j ) + minimumSquare ( m , n - j ) , vertical_min ) ; } dp [ m , n ] = Math . Min ( vertical_min , horizontal_min ) ; return dp [ m , n ] ; } public static void Main ( ) { int m = 30 , n = 35 ; Console . WriteLine ( minimumSquare ( m , n ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Matrix Chain Multiplication ( A O ( N ^ 2 ) Solution ) | Matrix Mi has dimension p [ i - 1 ] x p [ i ] for i = 1. . n ; For simplicity of the program , one extra row and one extra column are allocated in dp [ ] [ ] . 0 th row and 0 th column of dp [ ] [ ] are not used ; cost is zero when multiplying one matrix . ; Simply following above recursive formula . ; Driver code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def MatrixChainOrder ( p , n ) :\\n\\tdp = [ [ 0 for i in range ( n ) ] for i in range ( n ) ]\\n\\tfor i in range ( 1 , n ) :\\n\\t\\tdp [ i ] [ i ] = 0\\n\\tfor L in range ( 1 , n - 1 ) :\\n\\t\\tfor i in range ( n - L ) :\\n\\t\\t\\tdp [ i ] [ i + L ] = min ( dp [ i + 1 ] [ i + L ] + p [ i - 1 ] * p [ i ] * p [ i + L ] , dp [ i ] [ i + L - 1 ] + p [ i - 1 ] * p [ i + L - 1 ] * p [ i + L ] )\\n\\treturn dp [ 1 ] [ n - 1 ]\\narr = [ 10 , 20 , 30 , 40 , 30 ]\\nsize = len ( arr )\\nprint ( \\\" Minimum ▁ number ▁ of ▁ multiplications ▁ is \\\" , MatrixChainOrder ( arr , size ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Maximum length prefix such that frequency of each character is atmost number of characters with minimum frequency | C ++ implementation to find the prefix of the s such that occurrence of each character is atmost the count of minimum frequency in the s ; Function to find the maximum possible prefix of the s ; Hash map to store the frequency of the characters in the s ; Iterate over the s to find the occurence of each Character ; Minimum frequency of the Characters ; Loop to find the count of minimum frequency in the hash - map ; Loop to find the maximum possible length of the prefix in the s ; Condition to check if the frequency is greater than minimum possible freq ; maxprefix s and its length . ; Driver code ; s is initialize . ; str is passed in MaxPrefix function .\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; void MaxPrefix ( string s ) { map < char , int > Dict ; for ( char i : s ) { Dict [ i ] ++ ; } int minfrequency = INT_MAX ; for ( auto x : Dict ) { minfrequency = min ( minfrequency , x . second ) ; } int countminFrequency = 0 ; for ( auto x : Dict ) { if ( x . second == minfrequency ) countminFrequency += 1 ; } map < char , int > mapper ; int indi = 0 ; for ( char i : s ) { mapper [ i ] += 1 ; if ( mapper [ i ] > countminFrequency ) break ; indi += 1 ; } cout << ( s . substr ( 0 , indi ) ) ; } int main ( ) { string str = \\\" aabcdaab \\\" ; MaxPrefix ( str ) ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Make two numbers equal by multiplying with their prime factors minimum number of times | C # program for the above approach ; Everything divides 0 ; Function to calculate total number of prime factor with their prime factor ; Iterate while the number is even ; Reduce to half ; Iterate up to sqrt ( N ) ; Iterate while N has factors of i ; Removing one factor of i ; Function to count the number of factors ; Find the GCD ; Find multiples left in X and Y ; Find prime factor of multiple left in X and Y ; Initialize ans ; Check if it possible to obtain X or not ; Check if it possible to obtain Y or not ; Return main ans ; Driver Code ; Given Input ; Function Call\\\"\\nSolution in C#:\",\"targets\":\"using System ; using System . Collections . Generic ; class GFG { static int gcd ( int a , int b ) { if ( b == 0 ) { return a ; } return gcd ( b , a % b ) ; } static Dictionary < int , int > PrimeFactor ( int N ) { Dictionary < int , int > primef = new Dictionary < int , int > ( ) ; while ( N % 2 == 0 ) { if ( primef . ContainsKey ( 2 ) ) { primef [ 2 ] ++ ; } else { primef [ 2 ] = 1 ; } N = N \\/ 2 ; } for ( int i = 3 ; i <= Math . Sqrt ( N ) ; i ++ ) { while ( N % i == 0 ) { if ( primef . ContainsKey ( i ) ) { primef [ i ] ++ ; } else { primef [ i ] = 1 ; } N = N \\/ 2 ; } } if ( N > 2 ) { primef [ N ] = 1 ; } return primef ; } static int CountToMakeEqual ( int X , int Y ) { int gcdofXY = gcd ( X , Y ) ; int newX = Y \\/ gcdofXY ; int newY = X \\/ gcdofXY ; Dictionary < int , int > primeX = PrimeFactor ( newX ) ; Dictionary < int , int > primeY = PrimeFactor ( newY ) ; int ans = 0 ; foreach ( KeyValuePair < int , int > keys in primeX ) { if ( X % keys . Key != 0 ) { return - 1 ; } ans += primeX [ keys . Key ] ; } foreach ( KeyValuePair < int , int > keys in primeY ) { if ( Y % keys . Key != 0 ) { return - 1 ; } ans += primeY [ keys . Key ] ; } return ans ; } static void Main ( ) { int X = 36 ; int Y = 48 ; int ans = CountToMakeEqual ( X , Y ) ; Console . Write ( ans ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Check if a Binary Tree is an Even | C ++ program for the above approach ; Tree node ; Function to return new tree node ; Function to check if the tree is even - odd tree ; Stores nodes of each level ; Store the current level of the binary tree ; Traverse until the queue is empty ; Stores the number of nodes present in the current level ; Check if the level is even or odd ; Add the nodes of the next level into the queue ; Increment the level count ; Driver Code ; Construct a Binary Tree ; Check if the binary tree is even - odd tree or not\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; struct Node { int val ; Node * left , * right ; } ; struct Node * newNode ( int data ) { struct Node * temp = ( struct Node * ) malloc ( sizeof ( struct Node ) ) ; temp -> val = data ; temp -> left = NULL ; temp -> right = NULL ; return temp ; } bool isEvenOddBinaryTree ( Node * root ) { if ( root == NULL ) return true ; queue < Node * > q ; q . push ( root ) ; int level = 0 ; while ( ! q . empty ( ) ) { int size = q . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) { Node * node = q . front ( ) ; if ( level % 2 == 0 ) { if ( node -> val % 2 == 1 ) return false ; } else if ( level % 2 == 1 ) { if ( node -> val % 2 == 0 ) return true ; } if ( node -> left != NULL ) { q . push ( node -> left ) ; } if ( node -> right != NULL ) { q . push ( node -> right ) ; } } level ++ ; } return true ; } int main ( ) { Node * root = NULL ; root = newNode ( 2 ) ; root -> left = newNode ( 3 ) ; root -> right = newNode ( 9 ) ; root -> left -> left = newNode ( 4 ) ; root -> left -> right = newNode ( 10 ) ; root -> right -> right = newNode ( 6 ) ; if ( isEvenOddBinaryTree ( root ) ) cout << \\\" YES \\\" ; else cout << \\\" NO \\\" ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Rearrange positive and negative numbers with constant extra space | A utility function to print an array of size n ; Function to Rearrange positive and negative numbers in a array ; if current element is positive do nothing ; if current element is negative , shift positive elements of arr [ 0. . i - 1 ] , to one position to their right ; Put negative element at its right position ; Driver Code\\\"\\nSolution in Javascript:\",\"targets\":\"function printArray ( arr , n ) { for ( let i = 0 ; i < n ; i ++ ) document . write ( arr [ i ] + \\\" \\\" ) ; document . write ( \\\" \\\" ) ; } function RearrangePosNeg ( arr , n ) { let key , j ; for ( let i = 1 ; i < n ; i ++ ) { key = arr [ i ] ; if ( key > 0 ) continue ; j = i - 1 ; while ( j >= 0 && arr [ j ] > 0 ) { arr [ j + 1 ] = arr [ j ] ; j = j - 1 ; } arr [ j + 1 ] = key ; } } let arr = [ - 12 , 11 , - 13 , - 5 , 6 , - 7 , 5 , - 3 , - 6 ] ; let n = arr . length ; RearrangePosNeg ( arr , n ) ; printArray ( arr , n ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Sum of minimum element of all sub | Function to find the sum of minimum of all subsequence ; Driver code\\\"\\nSolution in Javascript:\",\"targets\":\"function findMinSum ( arr , n ) { var occ = n - 1 , sum = 0 ; for ( var i = 0 ; i < n ; i ++ ) { sum += arr [ i ] * Math . pow ( 2 , occ ) ; occ -- ; } return sum ; } var arr = [ 1 , 2 , 4 , 5 ] ; var n = arr . length ; document . write ( findMinSum ( arr , n ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Minimum removals required to make a given array Bitonic | Java program to implement the above approach ; Function to coutnt minimum array elements required to be removed to make an array bitonic ; left [ i ] : Stores the length of LIS up to i - th index ; right [ i ] : Stores the length of decreasing subsequence over the range [ i , N ] ; Calculate the length of LIS up to i - th index ; Traverse the array upto i - th index ; If arr [ j ] is less than arr [ i ] ; Update left [ i ] ; Calculate the length of decreasing subsequence over the range [ i , N ] ; Traverse right [ ] array ; If arr [ i ] is greater than arr [ j ] ; Update right [ i ] ; Stores length of the longest bitonic array ; Traverse left [ ] and right [ ] array ; Update maxLen ; Function to print minimum removals required to make given array bitonic ; Driver Code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"class GFG { static void min_element_removal ( int arr [ ] , int N ) { int left [ ] = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) left [ i ] = 1 ; int right [ ] = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) right [ i ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { if ( arr [ j ] < arr [ i ] ) { left [ i ] = Math . max ( left [ i ] , left [ j ] + 1 ) ; } } } for ( int i = N - 2 ; i >= 0 ; i -- ) { for ( int j = N - 1 ; j > i ; j -- ) { if ( arr [ i ] > arr [ j ] ) { right [ i ] = Math . max ( right [ i ] , right [ j ] + 1 ) ; } } } int maxLen = 0 ; for ( int i = 1 ; i < N - 1 ; i ++ ) { maxLen = Math . max ( maxLen , left [ i ] + right [ i ] - 1 ) ; } System . out . println ( N - maxLen ) ; } static void makeBitonic ( int arr [ ] , int N ) { if ( N == 1 ) { System . out . println ( \\\"0\\\" ) ; return ; } if ( N == 2 ) { if ( arr [ 0 ] != arr [ 1 ] ) System . out . println ( \\\"0\\\" ) ; else System . out . println ( \\\"1\\\" ) ; return ; } min_element_removal ( arr , N ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 1 , 1 , 5 , 6 , 2 , 3 , 1 } ; int N = arr . length ; makeBitonic ( arr , N ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Length of the longest subsegment which is UpDown after inserting atmost one integer | Java implementation of the approach ; Function to recursively fill the dp array ; If f ( i , state ) is already calculated then return the value ; Calculate f ( i , state ) according to the recurrence relation and store in dp [ ] [ ] ; Function that calls the resucrsive function to fill the dp array and then returns the result ; dp [ ] [ ] array for storing result of f ( i , 1 ) and f ( 1 , 2 ) ; Populating the array dp [ ] with - 1 ; Make sure that longest UD and DU sequence starting at each index is calculated ; Assume the answer to be - 1 This value will only increase ; y is the length of the longest UD sequence starting at i ; If length is even then add an integer and then a DU sequence starting at i + y ; If length is odd then add an integer and then a UD sequence starting at i + y ; Driver code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"class GFG { static int f ( int i , int state , int A [ ] , int dp [ ] [ ] , int N ) { if ( i >= N ) return 0 ; else if ( dp [ i ] [ state ] != - 1 ) { return dp [ i ] [ state ] ; } else { if ( i == N - 1 ) dp [ i ] [ state ] = 1 ; else if ( state == 1 && A [ i ] > A [ i + 1 ] ) dp [ i ] [ state ] = 1 ; else if ( state == 2 && A [ i ] < A [ i + 1 ] ) dp [ i ] [ state ] = 1 ; else if ( state == 1 && A [ i ] <= A [ i + 1 ] ) dp [ i ] [ state ] = 1 + f ( i + 1 , 2 , A , dp , N ) ; else if ( state == 2 && A [ i ] >= A [ i + 1 ] ) dp [ i ] [ state ] = 1 + f ( i + 1 , 1 , A , dp , N ) ; return dp [ i ] [ state ] ; } } static int maxLenSeq ( int A [ ] , int N ) { int i , j , tmp , y , ans ; int dp [ ] [ ] = new int [ 1000 ] [ 3 ] ; for ( i = 0 ; i < 1000 ; i ++ ) for ( j = 0 ; j < 3 ; j ++ ) dp [ i ] [ j ] = - 1 ; for ( i = 0 ; i < N ; i ++ ) { tmp = f ( i , 1 , A , dp , N ) ; tmp = f ( i , 2 , A , dp , N ) ; } ans = - 1 ; for ( i = 0 ; i < N ; i ++ ) { y = dp [ i ] [ 1 ] ; if ( i + y >= N ) ans = Math . max ( ans , dp [ i ] [ 1 ] + 1 ) ; else if ( y % 2 == 0 ) { ans = Math . max ( ans , dp [ i ] [ 1 ] + 1 + dp [ i + y ] [ 2 ] ) ; } else if ( y % 2 == 1 ) { ans = Math . max ( ans , dp [ i ] [ 1 ] + 1 + dp [ i + y ] [ 1 ] ) ; } } return ans ; } public static void main ( String [ ] args ) { int A [ ] = { 1 , 10 , 3 , 20 , 25 , 24 } ; int n = A . length ; System . out . println ( maxLenSeq ( A , n ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Program to implement Simpson 's 3\\/8 rule | CPP program to implement Simpson 's rule ; Given function to be integrated ; Function to perform calculations ; Calculates value till integral limit ; Driver Code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; float func ( float x ) { return ( 1 \\/ ( 1 + x * x ) ) ; } float calculate ( float lower_limit , float upper_limit , int interval_limit ) { float value ; float interval_size = ( upper_limit - lower_limit ) \\/ interval_limit ; float sum = func ( lower_limit ) + func ( upper_limit ) ; for ( int i = 1 ; i < interval_limit ; i ++ ) { if ( i % 3 == 0 ) sum = sum + 2 * func ( lower_limit + i * interval_size ) ; else sum = sum + 3 * func ( lower_limit + i * interval_size ) ; } return ( 3 * interval_size \\/ 8 ) * sum ; } int main ( ) { int interval_limit = 10 ; float lower_limit = 1 ; float upper_limit = 10 ; float integral_res = calculate ( lower_limit , upper_limit , interval_limit ) ; cout << integral_res ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Euler zigzag numbers ( Alternating Permutation ) | Java program to find zigzag sequence ; Function to print first n zigzag numbers ; To store factorial and n 'th zig zag number ; Initialize factorial upto n ; Set first two zig zag numbers ; Print first two zig zag number ; Print the rest zig zag numbers ; Binomial ( n , k ) * a ( k ) * a ( n - k ) ; Store the value ; Print the number ; Driver code ; Function call\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static void ZigZag ( int n ) { long [ ] fact = new long [ n + 1 ] ; long [ ] zig = new long [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) zig [ i ] = 0 ; fact [ 0 ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) fact [ i ] = fact [ i - 1 ] * i ; zig [ 0 ] = 1 ; zig [ 1 ] = 1 ; System . out . print ( \\\" zig ▁ zag ▁ numbers : ▁ \\\" ) ; System . out . print ( zig [ 0 ] + \\\" ▁ \\\" + zig [ 1 ] + \\\" ▁ \\\" ) ; for ( int i = 2 ; i < n ; i ++ ) { long sum = 0 ; for ( int k = 0 ; k <= i - 1 ; k ++ ) { sum += ( fact [ i - 1 ] \\/ ( fact [ i - 1 - k ] * fact [ k ] ) ) * zig [ k ] * zig [ i - 1 - k ] ; } zig [ i ] = sum \\/ 2 ; System . out . print ( sum \\/ 2 + \\\" ▁ \\\" ) ; } } public static void main ( String [ ] args ) throws java . lang . Exception { int n = 10 ; ZigZag ( n ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Decode the string encoded with the given algorithm | C ++ implementation of the approach ; Function to decode and print the original string ; To store the decoded string ; Getting the mid element ; Storing the first element of the string at the median position ; If the length is even then store the second element also ; k represents the number of characters that are already stored in the c [ ] ; If string length is odd ; If it is even ; Print the decoded string ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; void decodeStr ( string str , int len ) { char c [ len ] = \\\" \\\" ; int med , pos = 1 , k ; if ( len % 2 == 1 ) med = len \\/ 2 ; else med = len \\/ 2 - 1 ; c [ med ] = str [ 0 ] ; if ( len % 2 == 0 ) c [ med + 1 ] = str [ 1 ] ; if ( len & 1 ) k = 1 ; else k = 2 ; for ( int i = k ; i < len ; i += 2 ) { c [ med - pos ] = str [ i ] ; if ( len % 2 == 1 ) c [ med + pos ] = str [ i + 1 ] ; else c [ med + pos + 1 ] = str [ i + 1 ] ; pos ++ ; } for ( int i = 0 ; i < len ; i ++ ) cout << c [ i ] ; } int main ( ) { string str = \\\" ofrsgkeeeekgs \\\" ; int len = str . length ( ) ; decodeStr ( str , len ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Bitwise OR of bitwise AND of all possible non | Function to find the Bitwise OR of Bitwise AND of all possible subarrays after performing the every query ; Traversing each pair of the query ; Stores the Bitwise OR ; Updating the array ; Find the Bitwise OR of new updated array ; Print the ans ; Driver Code\\\"\\nSolution in Javascript:\",\"targets\":\"function performQuery ( arr , Q ) { for ( let i = 0 ; i < Q . length ; i ++ ) { let or = 0 ; let x = Q [ i ] [ 0 ] ; arr [ x - 1 ] = Q [ i ] [ 1 ] ; for ( let j = 0 ; j < arr . length ; j ++ ) { or = or | arr [ j ] ; } document . write ( or + \\\" \\\" ) ; } } let arr = [ 1 , 2 , 3 ] ; let Q = [ [ 1 , 4 ] , [ 3 , 0 ] ] ; performQuery ( arr , Q ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Count numbers up to N whose rightmost set bit is K | Function to count the numbers in the range [ 1 , N ] whose rightmost set bit is K ; Stores the number whose rightmost set bit is K ; Numbers whose rightmost set bit is i ; Subtracting the number whose rightmost set bit is i , from N ; Since i = k , then the number whose rightmost set bit is K is stored ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def countNumberHavingKthBitSet ( N , K ) :\\n\\tnumbers_rightmost_setbit_K = 0\\n\\tfor i in range ( 1 , K + 1 ) :\\n\\t\\tnumbers_rightmost_bit_i = ( N + 1 ) \\/\\/ 2\\n\\t\\tN -= numbers_rightmost_bit_i\\n\\t\\tif ( i == K ) :\\n\\t\\t\\tnumbers_rightmost_setbit_K = numbers_rightmost_bit_i\\n\\tprint ( numbers_rightmost_setbit_K )\\nif __name__ == ' _ _ main _ _ ' :\\n\\tN = 15\\n\\tK = 2\\n\\tcountNumberHavingKthBitSet ( N , K )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Count ways to construct array with even product from given array such that absolute difference of same indexed elements is at most 1 | C ++ program to implement the above approach ; Function to find count the ways to construct an array , B [ ] such that abs ( A [ i ] - B [ i ] ) <= 1 and product of elements of B [ ] is even ; Stores count of arrays B [ ] such that abs ( A [ i ] - B [ i ] ) <= 1 ; Stores count of arrays B [ ] whose product of elements is not even ; Traverse the array ; Update total ; If A [ i ] is an even number ; Update oddArray ; Print 3 ^ N - 2 ^ X ; Driver Code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; void cntWaysConsArray ( int A [ ] , int N ) { int total = 1 ; int oddArray = 1 ; for ( int i = 0 ; i < N ; i ++ ) { total = total * 3 ; if ( A [ i ] % 2 == 0 ) { oddArray *= 2 ; } } cout << total - oddArray << \\\" \\n \\\" ; } int main ( ) { int A [ ] = { 2 , 4 } ; int N = sizeof ( A ) \\/ sizeof ( A [ 0 ] ) ; cntWaysConsArray ( A , N ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Smallest greater elements in whole array | Simple PHP program to find smallest greater element in whole array for every element . ; Find the closest greater element for arr [ j ] in the entire array . ; Check if arr [ i ] is largest ; Driver code\\\"\\nSolution in php:\",\"targets\":\"< ? php function smallestGreater ( $ arr , $ n ) { for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { $ diff = PHP_INT_MAX ; $ closest = -1 ; for ( $ j = 0 ; $ j < $ n ; $ j ++ ) { if ( $ arr [ $ i ] < $ arr [ $ j ] && $ arr [ $ j ] - $ arr [ $ i ] < $ diff ) { $ diff = $ arr [ $ j ] - $ arr [ $ i ] ; $ closest = $ j ; } } if ( $ closest == -1 ) echo \\\" _ ▁ \\\" ; else echo $ arr [ $ closest ] , \\\" ▁ \\\" ; } } $ ar = array ( 6 , 3 , 9 , 8 , 10 , 2 , 1 , 15 , 7 ) ; $ n = sizeof ( $ ar ) ; smallestGreater ( $ ar , $ n ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Minimum changes to a string to make all substrings distinct | C # program to count number of changes to make all substrings distinct . ; Returns minimum changes to str so that no substring is repeated . ; If length is more than maximum allowed characters , we cannot get the required string . ; Variable to store count of distinct characters ; To store counts of different characters ; Answer is , n - number of distinct char ; Driver function\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static int MAX_CHAR = 26 ; public static int minChanges ( string str ) { int n = str . Length ; if ( n > MAX_CHAR ) return - 1 ; int dist_count = 0 ; int [ ] count = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) count [ i ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( count [ str [ i ] - ' a ' ] == 0 ) dist_count ++ ; count [ str [ i ] - ' a ' ] ++ ; } return ( n - dist_count ) ; } public static void Main ( ) { string str = \\\" aebaecedabbee \\\" ; Console . WriteLine ( minChanges ( str ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Count ways to reach the nth stair using step 1 , 2 or 3 | A recursive function used by countWays ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function countWays ( $ n ) { $ res [ 0 ] = 1 ; $ res [ 1 ] = 1 ; $ res [ 2 ] = 2 ; for ( $ i = 3 ; $ i <= $ n ; $ i ++ ) $ res [ $ i ] = $ res [ $ i - 1 ] + $ res [ $ i - 2 ] + $ res [ $ i - 3 ] ; return $ res [ $ n ] ; } $ n = 4 ; echo countWays ( $ n ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Gould 's Sequence | JAVA program to generate Gould 's Sequence ; Utility function to count odd numbers in ith row of Pascals 's triangle ; Initialize count as zero ; Return 2 ^ count ; Function to generate gould 's Sequence ; loop to generate gould 's Sequence up to n ; Driver code ; Get n ; Function call\\\"\\nHow can the above be solved in Java?\",\"targets\":\"class GFG { static int countOddNumber ( int row_num ) { int count = 0 ; while ( row_num > 0 ) { count += row_num & 1 ; row_num >>= 1 ; } return ( 1 << count ) ; } static void gouldSequence ( int n ) { for ( int row_num = 0 ; row_num < n ; row_num ++ ) { System . out . print ( countOddNumber ( row_num ) + \\\" ▁ \\\" ) ; } } public static void main ( String [ ] args ) { int n = 16 ; gouldSequence ( n ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Find maximum average subarray of k length | C # program to find maximum average subarray of given length . ; Returns beginning index of maximum average subarray of length ' k ' ; Check if ' k ' is valid ; Create and fill array to store cumulative sum . csum [ i ] stores sum of arr [ 0 ] to arr [ i ] ; Initialize max_sm as sum of first subarray ; Find sum of other subarrays and update max_sum if required . ; Return starting index ; Driver Code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int findMaxAverage ( int [ ] arr , int n , int k ) { if ( k > n ) return - 1 ; int [ ] csum = new int [ n ] ; csum [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) csum [ i ] = csum [ i - 1 ] + arr [ i ] ; int max_sum = csum [ k - 1 ] , max_end = k - 1 ; for ( int i = k ; i < n ; i ++ ) { int curr_sum = csum [ i ] - csum [ i - k ] ; if ( curr_sum > max_sum ) { max_sum = curr_sum ; max_end = i ; } } return max_end - k + 1 ; } static public void Main ( ) { int [ ] arr = { 1 , 12 , - 5 , - 6 , 50 , 3 } ; int k = 4 ; int n = arr . Length ; Console . WriteLine ( \\\" The ▁ maximum ▁ average ▁ subarray ▁ of ▁ \\\" + \\\" length ▁ \\\" + k + \\\" ▁ begins ▁ at ▁ index ▁ \\\" + findMaxAverage ( arr , n , k ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Write a program to calculate pow ( x , n ) | C # code for extended version of power function that can work for float x and negative y ; Program to test function power\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; public class GFG { static float power ( float x , int y ) { float temp ; if ( y == 0 ) return 1 ; temp = power ( x , y \\/ 2 ) ; if ( y % 2 == 0 ) return temp * temp ; else { if ( y > 0 ) return x * temp * temp ; else return ( temp * temp ) \\/ x ; } } public static void Main ( ) { float x = 2 ; int y = - 3 ; Console . Write ( power ( x , y ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Count subarrays having each distinct element occurring at least twice | Function to get the count of subarrays having each element occurring at least twice ; Stores count of subarrays having each distinct element occurring at least twice ; Stores count of unique elements in a subarray ; Store frequency of each element of a subarray ; Traverse the given array ; Count frequency and check conditions for each subarray ; Update frequency ; Check if frequency of arr [ j ] equal to 1 ; Update Count of unique elements ; Update count of unique elements ; If each element of subarray occurs at least twice ; Update cntSub ; Remove all elements from the subarray ; Update cntUnique ; Driver Code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function cntSubarrays ( arr , N ) { var cntSub = 0 ; var cntUnique = 0 ; var cntFreq = new Map ( ) ; for ( var i = 0 ; i < N ; i ++ ) { for ( var j = i ; j < N ; j ++ ) { if ( cntFreq . has ( arr [ j ] ) ) cntFreq . set ( arr [ j ] , cntFreq . get ( arr [ j ] ) + 1 ) else cntFreq . set ( arr [ j ] , 1 ) ; if ( cntFreq . get ( arr [ j ] ) == 1 ) { cntUnique ++ ; } else if ( cntFreq . get ( arr [ j ] ) == 2 ) { cntUnique -- ; } if ( cntUnique == 0 ) { cntSub ++ ; } } cntFreq = new Map ( ) ; cntUnique = 0 ; } return cntSub ; } var arr = [ 1 , 1 , 2 , 2 , 2 ] ; var N = arr . length ; document . write ( cntSubarrays ( arr , N ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Queries for the product of first N factorials | Java implementation of the approach ; Declare result array globally ; Function to precompute the product of factorials upto MAX ; Initialize base condition if n = 0 then factorial of 0 is equal to 1 and answer for n = 0 is 1 ; Iterate loop from 1 to MAX ; factorial ( i ) = factorial ( i - 1 ) * i ; Result for current n is equal to result [ i - 1 ] multiplied by the factorial of i ; Function to perform the queries ; Precomputing the result till MAX ; Perform queries ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"import java . io . * ; class GFG { static int MAX = 1000000 ; static int MOD = 10000007 ; static int [ ] result = new int [ MAX + 1 ] ; static int [ ] fact = new int [ MAX + 1 ] ; static void preCompute ( ) { fact [ 0 ] = 1 ; result [ 0 ] = 1 ; for ( int i = 1 ; i <= MAX ; i ++ ) { fact [ i ] = ( ( fact [ i - 1 ] % MOD ) * i ) % MOD ; result [ i ] = ( ( result [ i - 1 ] % MOD ) * ( fact [ i ] % MOD ) ) % MOD ; } } static void performQueries ( int q [ ] , int n ) { preCompute ( ) ; for ( int i = 0 ; i < n ; i ++ ) System . out . println ( result [ q [ i ] ] ) ; } public static void main ( String [ ] args ) { int q [ ] = { 4 , 5 } ; int n = q . length ; performQueries ( q , n ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Number of ways to arrange a word such that all vowels occur together | Factorial of a number ; calculating ways for arranging consonants ; Ignore vowels ; calculating ways for arranging vowels ; Function to count total no . of ways ; Count vowels and consonant ; total no . of ways ; Driver code\\\"\\nSolution in Python:\",\"targets\":\"def fact ( n ) :\\n\\tf = 1\\n\\tfor i in range ( 2 , n + 1 ) :\\n\\t\\tf = f * i\\n\\treturn f\\ndef waysOfConsonants ( size1 , freq ) :\\n\\tans = fact ( size1 )\\n\\tfor i in range ( 26 ) :\\n\\t\\tif ( i == 0 or i == 4 or i == 8 or i == 14 or i == 20 ) :\\n\\t\\t\\tcontinue\\n\\t\\telse :\\n\\t\\t\\tans = ans \\/\\/ fact ( freq [ i ] )\\n\\treturn ans\\ndef waysOfVowels ( size2 , freq ) :\\n\\treturn ( fact ( size2 ) \\/\\/ ( fact ( freq [ 0 ] ) * fact ( freq [ 4 ] ) * fact ( freq [ 8 ] ) * fact ( freq [ 14 ] ) * fact ( freq [ 20 ] ) ) )\\ndef countWays ( str1 ) :\\n\\tfreq = [ 0 ] * 26\\n\\tfor i in range ( len ( str1 ) ) :\\n\\t\\tfreq [ ord ( str1 [ i ] ) - ord ( ' a ' ) ] += 1\\n\\tvowel = 0\\n\\tconsonant = 0\\n\\tfor i in range ( len ( str1 ) ) :\\n\\t\\tif ( str1 [ i ] != ' a ' and str1 [ i ] != ' e ' and str1 [ i ] != ' i ' and str1 [ i ] != ' o ' and str1 [ i ] != ' u ' ) :\\n\\t\\t\\tconsonant += 1\\n\\t\\telse :\\n\\t\\t\\tvowel += 1\\n\\treturn ( waysOfConsonants ( consonant + 1 , freq ) * waysOfVowels ( vowel , freq ) )\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tstr1 = \\\" geeksforgeeks \\\"\\n\\tprint ( countWays ( str1 ) )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Minimum absolute difference between N and a power of 2 | Function to return the minimum difference between N and a power of 2 ; Power of 2 closest to n on its left ; Power of 2 closest to n on its right ; Return the minimum abs difference ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function minAbsDiff ( $ n ) { $ left = 1 << ( ( floor ( log ( $ n ) \\/ log ( 2 ) ) ) ) ; $ right = $ left * 2 ; return min ( ( $ n - $ left ) , ( $ right - $ n ) ) ; } $ n = 15 ; echo minAbsDiff ( $ n ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Count quadruplets with sum K from given array | ''Function to return the number of quadruplets having given sum ; '' Initialize answer ; '' All possible first elements ; '' All possible second element ; '' Use map to find the fourth element ; '' All possible third elements ; '' Calculate number of valid 4th elements ; '' Update the twice_count ; '' Unordered pairs ; '' Return answer ; ''Driver Code ; '' Given array arr[] ; '' Given sum S ; '' Function Call\\\"\\nSolution in Python:\",\"targets\":\"def countSum ( a , n , sum ) :\\n\\tcount = 0\\n\\tfor i in range ( n - 3 ) :\\n\\t\\tfor j in range ( i + 1 , n - 2 , 1 ) :\\n\\t\\t\\treq = sum - a [ i ] - a [ j ]\\n\\t\\t\\tm = { }\\n\\t\\t\\tfor k in range ( j + 1 , n , 1 ) :\\n\\t\\t\\t\\tm [ a [ k ] ] = m . get ( a [ k ] , 0 ) + 1\\n\\t\\t\\ttwice_count = 0\\n\\t\\t\\tfor k in range ( j + 1 , n , 1 ) :\\n\\t\\t\\t\\ttwice_count += m . get ( req - a [ k ] , 0 )\\n\\t\\t\\t\\tif ( req - a [ k ] == a [ k ] ) :\\n\\t\\t\\t\\t\\ttwice_count -= 1\\n\\t\\t\\tcount += twice_count \\/\\/ 2\\n\\treturn count\\nif __name__ == ' _ _ main _ _ ' :\\n\\tarr = [ 4 , 5 , 3 , 1 , 2 , 4 ]\\n\\tS = 13\\n\\tN = len ( arr )\\n\\tprint ( countSum ( arr , N , S ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Find the element in a linked list with frequency at least N \\/ 3 | Structure of a node for the linked list ; Function to find and return the element with frequency of at least N \\/ 3 ; Candidates for being the required majority element ; Store the frequencies of the respective candidates ; Iterate all nodes ; Increase frequency of candidate s ; Increase frequency of candidate t ; Set the new sting as candidate for majority ; Set the new sting as second candidate for majority ; Decrease the frequency ; Check the frequency of two final selected candidate linklist ; Increase the frequency of first candidate ; Increase the frequency of second candidate ; Return the string with higher frequency ; Driver code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"class Node :\\n\\tdef __init__ ( self , s ) :\\n\\t\\tself . i = s\\n\\t\\tself . next = None\\ndef Majority_in_linklist ( head ) :\\n\\ts , t = \\\" \\\" , \\\" \\\"\\n\\tp , q = 0 , 0\\n\\tptr = None\\n\\twhile head != None :\\n\\t\\tif s == head . i :\\n\\t\\t\\tp = p + 1\\n\\t\\telse :\\n\\t\\t\\tif t == head . i :\\n\\t\\t\\t\\tq = q + 1\\n\\t\\t\\telse :\\n\\t\\t\\t\\tif p == 0 :\\n\\t\\t\\t\\t\\ts = head . i\\n\\t\\t\\t\\t\\tp = 1\\n\\t\\t\\t\\telse :\\n\\t\\t\\t\\t\\tif q == 0 :\\n\\t\\t\\t\\t\\t\\tt = head . i\\n\\t\\t\\t\\t\\t\\tq = 1\\n\\t\\t\\t\\t\\telse :\\n\\t\\t\\t\\t\\t\\tp = p - 1\\n\\t\\t\\t\\t\\t\\tq = q - 1\\n\\t\\thead = head . next\\n\\thead = ptr\\n\\tp = 0\\n\\tq = 0\\n\\twhile head != None :\\n\\t\\tif s == head . i :\\n\\t\\t\\tp = 1\\n\\t\\telse :\\n\\t\\t\\tif t == head . i :\\n\\t\\t\\t\\tq = 1\\n\\t\\thead = head . next\\n\\tif p > q :\\n\\t\\treturn s\\n\\telse :\\n\\t\\treturn t\\nptr = None\\nhead = Node ( \\\" geeks \\\" )\\nhead . next = Node ( \\\" geeks \\\" )\\nhead . next . next = Node ( \\\" abcd \\\" )\\nhead . next . next . next = Node ( \\\" game \\\" )\\nhead . next . next . next . next = Node ( \\\" game \\\" )\\nhead . next . next . next . next . next = Node ( \\\" knight \\\" )\\nhead . next . next . next . next . next . next = Node ( \\\" harry \\\" )\\nhead . next . next . next . next . next . next . next = Node ( \\\" geeks \\\" )\\nprint ( Majority_in_linklist ( head ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"An efficient way to check whether n | Returns true if n - th Fibonacci number is multiple of 10. ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function isMultipleOf10 ( $ n ) { return ( $ n % 15 == 0 ) ; } $ n = 30 ; if ( isMultipleOf10 ( $ n ) ) echo \\\" Yes \\n \\\" ; else echo \\\" No \\n \\\" ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Count removal of pairs required to be empty all Balanced Parenthesis subsequences | Java program to implement the above approach ; Function to find the maximum count of pairs required to be removed such that subsequence of string does not contain any valid parenthesis ; Stores count of pairs of balanced parenthesis ; Stores count of curly balanced parenthesis ; Stores count of small balanced parenthesis ; Stores count of square balanced parenthesis ; Iterate over characters of the string ; Update cntCurly ; Update cntSml ; Update cntSqr ; Update cntCurly ; Update cntPairs ; Update cntSml ; Update cntPairs ; Update cntSml ; Update cntPairs ; Driver Code ; Given String ; Function call\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . io . * ; class GFG { static void cntBalancedParenthesis ( String s , int N ) { int cntPairs = 0 ; int cntCurly = 0 ; int cntSml = 0 ; int cntSqr = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( s . charAt ( i ) == ' { ' ) { cntCurly ++ ; } else if ( s . charAt ( i ) == ' ( ' ) { cntSml ++ ; } else if ( s . charAt ( i ) == ' [ ' ) { cntSqr ++ ; } else if ( s . charAt ( i ) == ' } ' && cntCurly > 0 ) { cntCurly -- ; cntPairs ++ ; } else if ( s . charAt ( i ) == ' ) ' && cntSml > 0 ) { cntSml -- ; cntPairs ++ ; } else if ( s . charAt ( i ) == ' ] ' && cntSqr > 0 ) { cntSqr -- ; cntPairs ++ ; } } System . out . println ( cntPairs ) ; } public static void main ( String [ ] args ) { String s = \\\" { ( } ) \\\" ; int N = s . length ( ) ; cntBalancedParenthesis ( s , N ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Summing the sum series | Function to calculate twice of sum of first N natural numbers ; Function to calculate the terms of summing of sum series ; Driver Code\\\"\\nSolution in Javascript:\",\"targets\":\"function sum ( N ) { let MOD = 1000000007 ; let val = N * ( N + 1 ) ; val = val % MOD ; return val ; } function sumX ( N , M , K ) { let MOD = 1000000007 ; for ( let i = 0 ; i < M ; i ++ ) { N = sum ( K + N ) ; } N = N % MOD ; return N ; } let N = 1 ; let M = 2 ; let K = 3 ; document . write ( sumX ( N , M , K ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Program for factorial of a number | C program to find factorial of given number ; function to find factorial of given number ; Driver Code\\\"\\nSolution in C:\",\"targets\":\"#include < stdio . h\\nunsigned int factorial ( unsigned int n ) { if ( n == 0 ) return 1 ; return n * factorial ( n - 1 ) ; } int main ( ) { int num = 5 ; printf ( \\\" Factorial ▁ of ▁ % d ▁ is ▁ % d \\\" , num , factorial ( num ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Largest number less than or equal to N \\/ 2 which is coprime to N | Function to find largest integer less than or equal to N \\/ 2 and is coprime with N ; Handle the case for N = 6 ; Driver code\\\"\\nSolution in php:\",\"targets\":\"< ? php function largestCoprime ( $ N ) { if ( $ N == 6 ) return 1 ; else if ( $ N % 4 == 0 ) return ( $ N \\/ 2 ) - 1 ; else if ( $ N % 2 == 0 ) return ( $ N \\/ 2 ) - 2 ; else return ( ( $ N - 1 ) \\/ 2 ) ; } $ n = 50 ; echo largestCoprime ( $ n ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Cost required to make all array elements equal to 1 | Java program for the above approach ; Function to calculate the cost required to make all array elements equal to 1 ; Stores the total cost ; Traverse the array arr [ ] ; If current element is 0 ; Convert 0 to 1 ; Add the cost ; Return the total cost ; Driver Code\\\"\\nSolution in Java:\",\"targets\":\"class GFG { static int findCost ( int [ ] A , int N ) { int totalCost = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( A [ i ] == 0 ) { A [ i ] = 1 ; totalCost += i ; } } return totalCost ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 0 , 1 , 0 , 1 , 0 } ; int N = arr . length ; System . out . println ( findCost ( arr , N ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Find the smallest and second smallest elements in an array | Python program to find smallest and second smallest elements ; Function to print first smallest and second smallest elements ; There should be atleast two elements ; If current element is smaller than first then update both first and second ; If arr [ i ] is in between first and second then update second ; Driver function to test above function\\\"\\nHow can the above be solved in Python?\",\"targets\":\"import sys\\ndef print2Smallest ( arr ) :\\n\\tarr_size = len ( arr )\\n\\tif arr_size < 2 :\\n\\t\\tprint \\\" Invalid ▁ Input \\\"\\n\\t\\treturn\\n\\tfirst = second = sys . maxint\\n\\tfor i in range ( 0 , arr_size ) :\\n\\t\\tif arr [ i ] < first :\\n\\t\\t\\tsecond = first\\n\\t\\t\\tfirst = arr [ i ]\\n\\t\\telif ( arr [ i ] < second and arr [ i ] != first ) :\\n\\t\\t\\tsecond = arr [ i ] ;\\n\\tif ( second == sys . maxint ) :\\n\\t\\tprint \\\" No ▁ second ▁ smallest ▁ element \\\"\\n\\telse :\\n\\t\\tprint ' The ▁ smallest ▁ element ▁ is ' , first , ' and ' ' ▁ second ▁ smallest ▁ element ▁ is ' , second\\narr = [ 12 , 13 , 1 , 10 , 34 , 1 ]\\nprint2Smallest ( arr )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Minimize K to let Person A consume at least ceil ( N \\/ ( M + 1 ) ) candies based on given rules | Java program for the above approach ; Function to find minimum value of K such that the first person gets at least ( N \\/ ( M + 1 ) ) candies ; Find the minimum required value of candies for the first person ; Iterate K from [ 1 , n ] ; Total number of candies ; Candies taken by Person 1 ; Candies taken by 1 st person is minimum of K and candies left ; Traverse the array arr [ ] ; Amount consumed by the person j ; Update the number of candies ; Good share of candies achieved ; Driver Code\\\"\\nSolution in Java:\",\"targets\":\"import java . util . * ; class GFG { static void minimumK ( ArrayList < Integer > arr , int M , int N ) { int good = ( int ) ( ( N * 1.0 ) \\/ ( ( M + 1 ) * 1.0 ) ) + 1 ; for ( int i = 1 ; i <= N ; i ++ ) { int K = i ; int candies = N ; int taken = 0 ; while ( candies > 0 ) { taken += Math . min ( K , candies ) ; candies -= Math . min ( K , candies ) ; for ( int j = 0 ; j < M ; j ++ ) { int consume = ( arr . get ( j ) * candies ) \\/ 100 ; candies -= consume ; } } if ( taken >= good ) { System . out . print ( i ) ; return ; } } } public static void main ( String [ ] args ) { int N = 13 , M = 1 ; ArrayList < Integer > arr = new ArrayList < Integer > ( ) ; arr . add ( 50 ) ; minimumK ( arr , M , N ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Arc length from given Angle | function to calculate arc length ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function arcLength ( $ diameter , $ angle ) { $ pi = 22.0 \\/ 7.0 ; $ arc ; if ( $ angle >= 360 ) { echo \\\" Angle ▁ cannot \\\" , \\\" ▁ be ▁ formed \\\" ; return 0 ; } else { $ arc = ( $ pi * $ diameter ) * ( $ angle \\/ 360.0 ) ; return $ arc ; } } $ diameter = 25.0 ; $ angle = 45.0 ; $ arc_len = arcLength ( $ diameter , $ angle ) ; echo ( $ arc_len ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Maximize occurrences of values between L and R on sequential addition of Array elements with modulo H | Function that prints the number of times X gets a value between L and R ; Base condition ; Condition if X can be made equal to j after i additions ; Compute value of X after adding arr [ i ] ; Compute value of X after adding arr [ i ] - 1 ; Update dp as the maximum value ; Compute maximum answer from all possible cases ; Printing maximum good occurrence of X ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"def goodInteger ( arr , n , h , l , r ) :\\n\\tdp = [ [ - 1 for i in range ( h ) ] for j in range ( n + 1 ) ]\\n\\tdp [ 0 ] [ 0 ] = 0\\n\\tfor i in range ( n ) :\\n\\t\\tfor j in range ( h ) :\\n\\t\\t\\tif ( dp [ i ] [ j ] != - 1 ) :\\n\\t\\t\\t\\th1 = ( j + arr [ i ] ) % h\\n\\t\\t\\t\\th2 = ( j + arr [ i ] - 1 ) % h\\n\\t\\t\\t\\tdp [ i + 1 ] [ h1 ] = max ( dp [ i + 1 ] [ h1 ] , dp [ i ] [ j ] + ( h1 >= l and h1 <= r ) )\\n\\t\\t\\t\\tdp [ i + 1 ] [ h2 ] = max ( dp [ i + 1 ] [ h2 ] , dp [ i ] [ j ] + ( h2 >= l and h2 <= r ) )\\n\\tans = 0\\n\\tfor i in range ( h ) :\\n\\t\\tif ( dp [ n ] [ i ] != - 1 ) :\\n\\t\\t\\tans = max ( ans , dp [ n ] [ i ] )\\n\\tprint ( ans )\\nif __name__ == ' _ _ main _ _ ' :\\n\\tA = [ 16 , 17 , 14 , 20 , 20 , 11 , 22 ]\\n\\tH = 24\\n\\tL = 21\\n\\tR = 23\\n\\tsize = len ( A )\\n\\tgoodInteger ( A , size , H , L , R )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Check if two circles intersect such that the third circle passes through their points of intersections and centers | C ++ program for the above approach ; Structure of the circle ; Utility function to check if given circles satisfy required criteria ; Stores the distance between the centres of C1 and C2 ; Stores the status if the given given criteria is satisfied or not ; If C1C2 is less than the sum of the radii of the first 2 circles ; If C3 is the midpoint of the centres at C1 and C2 ; Mark flag true ; Return flag ; Function to check if the given circles satisfy required criteria ; Check for the current combination of circles ; Check for the next combination ; Driver Code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; class circle { public : double x ; double y ; double r ; } ; bool check ( circle C [ ] ) { double C1C2 = sqrt ( ( C [ 1 ] . x - C [ 0 ] . x ) * ( C [ 1 ] . x - C [ 0 ] . x ) + ( C [ 1 ] . y - C [ 0 ] . y ) * ( C [ 1 ] . y - C [ 0 ] . y ) ) ; bool flag = 0 ; if ( C1C2 < ( C [ 0 ] . r + C [ 1 ] . r ) ) { if ( ( C [ 0 ] . x + C [ 1 ] . x ) == 2 * C [ 2 ] . x && ( C [ 0 ] . y + C [ 1 ] . y ) == 2 * C [ 2 ] . y ) { flag = 1 ; } } return flag ; } bool IsFairTriplet ( circle c [ ] ) { bool f = false ; f |= check ( c ) ; for ( int i = 0 ; i < 2 ; i ++ ) { swap ( c [ 0 ] , c [ 2 ] ) ; f |= check ( c ) ; } return f ; } int main ( ) { circle C [ 3 ] ; C [ 0 ] = { 0 , 0 , 8 } ; C [ 1 ] = { 0 , 10 , 6 } ; C [ 2 ] = { 0 , 5 , 5 } ; if ( IsFairTriplet ( C ) ) cout << \\\" Yes \\\" ; else cout << \\\" No \\\" ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Construct original array starting with K from an array of XOR of all elements except elements at same index | Function to construct an array with each element equal to XOR of all array elements except the element at the same index ; Original array ; Stores Bitwise XOR of array ; Calculate XOR of all array elements ; Print the original array B [ ] ; Driver Code ; Function Call\\\"\\nSolution in Javascript:\",\"targets\":\"function constructArray ( A , N , K ) { let B = new Array ( N ) ; let totalXOR = A [ 0 ] ^ K ; for ( let i = 0 ; i < N ; i ++ ) B [ i ] = totalXOR ^ A [ i ] ; for ( let i = 0 ; i < N ; i ++ ) { document . write ( B [ i ] + \\\" \\\" ) ; } } let A = [ 13 , 14 , 10 , 6 ] , K = 2 ; let N = A . length ; constructArray ( A , N , K ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Sort decreasing permutation of N using triple swaps | Function to sort array ; The three indices that has to be chosen ; Check if possible to sort array ; Swapping to bring element at required position Bringing at least one element at correct position ; Tracing changes in array ; Print the sorted array ; If not possible to sort ; Driver Code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function sortArray ( A , N ) { let x = 0 , y = 0 , z = 0 ; if ( N % 4 == 0 N % 4 == 1 ) { for ( let i = 0 ; i < N \\/ 2 ; i ++ ) { x = i ; if ( i % 2 == 0 ) { y = N - i - 2 ; z = N - i - 1 ; } A [ z ] = A [ y ] ; A [ y ] = A [ x ] ; A [ x ] = x + 1 ; } document . write ( \\\" \\\" ) ; for ( let i = 0 ; i < N ; i ++ ) document . write ( A [ i ] + \\\" \\\" ) ; } else { document . write ( \\\" \\\" ) ; } } let A = [ 5 , 4 , 3 , 2 , 1 ] ; let N = A . length ; sortArray ( A , N ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Maximum score assigned to a subsequence of numerically consecutive and distinct array elements | C ++ program for the above approach ; Function to find the maximum score possible ; Base Case ; If previously occurred subproblem occurred ; Check if lastpicked element differs by 1 from the current element ; Calculate score by including the current element ; Calculate score by excluding the current element ; Return maximum score from the two possibilities ; Function to print maximum score ; DP array to store results Initialise dp with - 1 ; Function call ; Driver code ; Given arrays ; Function call\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int maximumSum ( int a [ ] , int b [ ] , int n , int index , int lastpicked , vector < vector < int > > dp ) { if ( index == n ) return 0 ; if ( dp [ index ] [ lastpicked + 1 ] != -1 ) return dp [ index ] [ lastpicked + 1 ] ; int option1 = 0 , option2 = 0 ; if ( lastpicked == -1 a [ lastpicked ] != a [ index ] ) { option1 = b [ index ] + maximumSum ( a , b , n , index + 1 , index , dp ) ; } option2 = maximumSum ( a , b , n , index + 1 , lastpicked , dp ) ; return dp [ index ] [ lastpicked + 1 ] = max ( option1 , option2 ) ; } void maximumPoints ( int arr [ ] , int brr [ ] , int n ) { int index = 0 , lastPicked = -1 ; vector < vector < int > > dp ( n + 5 , vector < int > ( n + 5 , -1 ) ) ; cout << maximumSum ( arr , brr , n , index , lastPicked , dp ) << endl ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 3 , 3 , 1 } ; int brr [ ] = { -1 , 2 , 10 , 20 , -10 , -9 } ; int N = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; maximumPoints ( arr , brr , N ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Subset Sum Problem in O ( sum ) space | Returns true if there exists a subset with given sum in arr [ ] ; The value of subset [ i % 2 ] [ j ] will be true if there exists a subset of sum j in arr [ 0 , 1 , ... . , i - 1 ] ; A subset with sum 0 is always possible ; If there exists no element no sum is possible ; driver program\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function isSubsetSum ( arr , n , sum ) { let subset = new Array ( 2 ) ; for ( var i = 0 ; i < subset . length ; i ++ ) { subset [ i ] = new Array ( 2 ) ; } for ( let i = 0 ; i <= n ; i ++ ) { for ( let j = 0 ; j <= sum ; j ++ ) { if ( j == 0 ) subset [ i % 2 ] [ j ] = true ; else if ( i == 0 ) subset [ i % 2 ] [ j ] = false ; else if ( arr [ i - 1 ] <= j ) subset [ i % 2 ] [ j ] = subset [ ( i + 1 ) % 2 ] [ j - arr [ i - 1 ] ] || subset [ ( i + 1 ) % 2 ] [ j ] ; else subset [ i % 2 ] [ j ] = subset [ ( i + 1 ) % 2 ] [ j ] ; } } return subset [ n % 2 ] [ sum ] ; } let arr = [ 1 , 2 , 5 ] ; let sum = 7 ; let n = arr . length ; if ( isSubsetSum ( arr , n , sum ) == true ) document . write ( \\\" \\\" + \\\" \\\" ) ; else document . write ( \\\" \\\" + \\\" \\\" ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"String containing first letter of every word in a given string with spaces | Java program to find the string which contain the first character of each word of another string . ; Function to find string which has first character of each word . ; Traverse the string . ; If it is space , set v as true . ; Else check if v is true or not . If true , copy character in output string and set v as false . ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"class GFG { static String firstLetterWord ( String str ) { String result = \\\" \\\" ; boolean v = true ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == ' ▁ ' ) { v = true ; } else if ( str . charAt ( i ) != ' ▁ ' && v == true ) { result += ( str . charAt ( i ) ) ; v = false ; } } return result ; } public static void main ( String [ ] args ) { String str = \\\" geeks ▁ for ▁ geeks \\\" ; System . out . println ( firstLetterWord ( str ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Majority Element | Set | function to print the majorityNumber ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"def majorityNumber ( nums ) :\\n\\tnum_count = { }\\n\\tfor num in nums :\\n\\t\\tif num in num_count :\\n\\t\\t\\tnum_count [ num ] += 1\\n\\t\\telse :\\n\\t\\t\\tnum_count [ num ] = 1\\n\\tfor num in num_count :\\n\\t\\tif num_count [ num ] > len ( nums ) \\/ 2 :\\n\\t\\t\\treturn num\\n\\treturn - 1\\na = [ 2 , 2 , 1 , 1 , 1 , 2 , 2 ]\\nprint majorityNumber ( a )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"How to print maximum number of A 's using given four keys | this function returns the optimal length string for N keystrokes ; The optimal string length is N when N is smaller than 7 ; An array to store result of subproblems ; Initializing the optimal lengths array for uptil 6 input strokes . ; Solve all subproblems in bottom manner ; for any keystroke n , we will need to choose between : - 1. pressing Ctrl - V once after copying the A ' s ▁ obtained ▁ by ▁ n - 3 ▁ keystrokes . ▁ ▁ 2 . ▁ pressing ▁ Ctrl - V ▁ twice ▁ after ▁ copying ▁ the ▁ A ' s obtained by n - 4 keystrokes . 3. pressing Ctrl - V thrice after copying the A 's obtained by n-5 keystrokes. ; Driver Code ; for the rest of the array we will rely on the previous entries to compute new ones\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def findoptimal ( N ) :\\n\\tif ( N <= 6 ) :\\n\\t\\treturn N\\n\\tscreen = [ 0 ] * N\\n\\tfor n in range ( 1 , 7 ) :\\n\\t\\tscreen [ n - 1 ] = n\\n\\tfor n in range ( 7 , N + 1 ) :\\n\\t\\tscreen [ n - 1 ] = max ( 2 * screen [ n - 4 ] , max ( 3 * screen [ n - 5 ] , 4 * screen [ n - 6 ] ) ) ;\\n\\treturn screen [ N - 1 ]\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tfor N in range ( 1 , 21 ) :\\n\\t\\tprint ( \\\" Maximum ▁ Number ▁ of ▁ A ' s ▁ with ▁ \\\" , N , \\\" ▁ keystrokes ▁ is ▁ \\\" , findoptimal ( N ) )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Ways to Remove Edges from a Complete Graph to make Odd Edges | C ++ implementation of the approach ; Function to return the number of ways to remove edges from the graph so that odd number of edges are left in the graph ; Total number of edges ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int countWays ( int N ) { int E = ( N * ( N - 1 ) ) \\/ 2 ; if ( N == 1 ) return 0 ; return pow ( 2 , E - 1 ) ; } int main ( ) { int N = 4 ; cout << countWays ( N ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Given an n x n square matrix , find sum of all sub | A simple Java program to find sum of all subsquares of size k x k ; Size of given matrix ; A simple function to find sum of all sub - squares of size k x k in a given square matrix of size n x n ; k must be smaller than or equal to n ; row number of first cell in current sub - square of size k x k ; column of first cell in current sub - square of size k x k ; Calculate and print sum of current sub - square ; Line separator for sub - squares starting with next row ; Driver Program to test above function\\\"\\nHow can the above be solved in Java?\",\"targets\":\"class GFG { static final int n = 5 ; static void printSumSimple ( int mat [ ] [ ] , int k ) { if ( k > n ) return ; for ( int i = 0 ; i < n - k + 1 ; i ++ ) { for ( int j = 0 ; j < n - k + 1 ; j ++ ) { int sum = 0 ; for ( int p = i ; p < k + i ; p ++ ) for ( int q = j ; q < k + j ; q ++ ) sum += mat [ p ] [ q ] ; System . out . print ( sum + \\\" ▁ \\\" ) ; } System . out . println ( ) ; } } public static void main ( String arg [ ] ) { int mat [ ] [ ] = { { 1 , 1 , 1 , 1 , 1 } , { 2 , 2 , 2 , 2 , 2 } , { 3 , 3 , 3 , 3 , 3 } , { 4 , 4 , 4 , 4 , 4 } , { 5 , 5 , 5 , 5 , 5 } } ; int k = 3 ; printSumSimple ( mat , k ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Count the number of strings in an array whose distinct characters are less than equal to M | Function to count the strings whose distinct characters count is less than M ; Loop to iterate over all the strings of the array ; Distinct characters in the String with the help of set ; Checking if its less than or equal to M ; Driver Code\\\"\\nSolution in Javascript:\",\"targets\":\"function distinct ( S , M , n ) { let count = 0 ; for ( let i = 0 ; i < n ; i ++ ) { let set1 = new Set ( ) ; for ( let j = 0 ; j < S [ i ] . length ; j ++ ) { if ( ! set1 . has ( S [ i ] [ j ] ) ) set1 . add ( S [ i ] [ j ] ) ; } let c = set1 . size ; if ( c <= M ) count += 1 ; } document . write ( count ) ; } let S = [ \\\" \\\" , \\\" \\\" , \\\" \\\" ] ; let M = 7 ; let n = S . length ; distinct ( S , M , n ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Area of the biggest possible rhombus that can be inscribed in a rectangle | Function to find the area of the biggest rhombus ; the length and breadth cannot be negative ; area of the rhombus ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function rhombusarea ( $ l , $ b ) { if ( $ l < 0 $ b < 0 ) return -1 ; return ( $ l * $ b ) \\/ 2 ; } $ l = 16 ; $ b = 6 ; echo rhombusarea ( $ l , $ b ) . \\\" \\n \\\" ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Program to determine focal length of a spherical mirror | Determines focal length of a spherical concave mirror ; Determines focal length of a spherical convex mirror ; Driver function\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function focal_length_concave ( $ R ) { return $ R \\/ 2 ; } function focal_length_convex ( $ R ) { return - ( $ R \\/ 2 ) ; } $ R = 30 ; echo \\\" Focal ▁ length ▁ of ▁ spherical \\\" , \\\" concave ▁ mirror ▁ is ▁ : ▁ \\\" , focal_length_concave ( $ R ) , \\\" ▁ units \\n \\\" ; echo \\\" Focal ▁ length ▁ of ▁ spherical \\\" , \\\" ▁ convex ▁ mirror ▁ is ▁ : ▁ \\\" , focal_length_convex ( $ R ) , \\\" ▁ units \\\" ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Check if a number is prime in Flipped Upside Down , Mirror Flipped and Mirror Flipped Upside Down | C ++ program to implement the above approach ; Function to check if N contains digits 0 , 1 , 2 , 5 , 8 only ; Extract digits of N ; Return false if any of these digits are present ; Function to check if N is prime or not ; Check for all factors ; Function to check if n is prime in all the desired forms ; Driver Code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; bool checkDigits ( int n ) { do { int r = n % 10 ; if ( r == 3 r == 4 r == 6 r == 7 r == 9 ) return false ; n \\/= 10 ; } while ( n != 0 ) ; return true ; } bool isPrime ( int n ) { if ( n <= 1 ) return false ; for ( int i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) return false ; } return true ; } int isAllPrime ( int n ) { return isPrime ( n ) && checkDigits ( n ) ; } int main ( ) { int N = 101 ; if ( isAllPrime ( N ) ) cout << \\\" Yes \\\" ; else cout << \\\" No \\\" ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Central polygonal numbers | Function to find N - th term in the series ; Driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function findNthTerm ( n ) { document . write ( n * n - n + 1 ) ; } N = 4 ; findNthTerm ( N ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Finding a Non Transitive Co | Function to return gcd of a and b ; function to check for gcd ; a and b are coprime if their gcd is 1. ; Checks if any possible triplet ( a , b , c ) satifying the condition that ( a , b ) is coprime , ( b , c ) is coprime but ( a , c ) isnt ; Generate and check for all possible triplets between L and R ; if we find any such triplets set flag to true ; flag = True indicates that a pair exists between L and R ; finding possible Triplet between 2 and 10 ; finding possible Triplet between 23 and 46\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def gcd ( a , b ) :\\n\\tif ( a == 0 ) :\\n\\t\\treturn b ;\\n\\treturn gcd ( b % a , a ) ;\\ndef coprime ( a , b ) :\\n\\treturn ( gcd ( a , b ) == 1 ) ;\\ndef possibleTripletInRange ( L , R ) :\\n\\tflag = False ;\\n\\tpossibleA = 0 ;\\n\\tpossibleB = 0 ;\\n\\tpossibleC = 0 ;\\n\\tfor a in range ( L , R + 1 ) :\\n\\t\\tfor b in range ( a + 1 , R + 1 ) :\\n\\t\\t\\tfor c in range ( b + 1 , R + 1 ) :\\n\\t\\t\\t\\tif ( coprime ( a , b ) and coprime ( b , c ) and coprime ( a , c ) == False ) :\\n\\t\\t\\t\\t\\tflag = True ;\\n\\t\\t\\t\\t\\tpossibleA = a ;\\n\\t\\t\\t\\t\\tpossibleB = b ;\\n\\t\\t\\t\\t\\tpossibleC = c ;\\n\\t\\t\\t\\t\\tbreak ;\\n\\tif ( flag == True ) :\\n\\t\\tprint ( \\\" ( \\\" , possibleA , \\\" , \\\" , possibleB , \\\" , \\\" , possibleC , \\\" ) ▁ is ▁ one ▁ such \\\" , \\\" possible ▁ triplet ▁ between \\\" , L , \\\" and \\\" , R ) ;\\n\\telse :\\n\\t\\tprint ( \\\" No ▁ Such ▁ Triplet ▁ exists ▁ between \\\" , L , \\\" and \\\" , R ) ;\\nL = 2 ;\\nR = 10 ;\\npossibleTripletInRange ( L , R ) ;\\nL = 23 ;\\nR = 46 ;\\npossibleTripletInRange ( L , R ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Write a function to get the intersection point of two Linked Lists | Java program to get intersection point of two linked list ; list 1 ; list 2 ; function to print the list ; function to find the intersection of two node ; define hashset\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class Node { int data ; Node next ; Node ( int d ) { data = d ; next = null ; } } class LinkedListIntersect { public static void main ( String [ ] args ) { Node n1 = new Node ( 1 ) ; n1 . next = new Node ( 2 ) ; n1 . next . next = new Node ( 3 ) ; n1 . next . next . next = new Node ( 4 ) ; n1 . next . next . next . next = new Node ( 5 ) ; n1 . next . next . next . next . next = new Node ( 6 ) ; n1 . next . next . next . next . next . next = new Node ( 7 ) ; Node n2 = new Node ( 10 ) ; n2 . next = new Node ( 9 ) ; n2 . next . next = new Node ( 8 ) ; n2 . next . next . next = n1 . next . next . next ; Print ( n1 ) ; Print ( n2 ) ; System . out . println ( MegeNode ( n1 , n2 ) . data ) ; } public static void Print ( Node n ) { Node cur = n ; while ( cur != null ) { System . out . print ( cur . data + \\\" ▁ \\\" ) ; cur = cur . next ; } System . out . println ( ) ; } public static Node MegeNode ( Node n1 , Node n2 ) { HashSet < Node > hs = new HashSet < Node > ( ) ; while ( n1 != null ) { hs . add ( n1 ) ; n1 = n1 . next ; } while ( n2 != null ) { if ( hs . contains ( n2 ) ) { return n2 ; } n2 = n2 . next ; } return null ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Partition problem | DP | Returns true if arr [ ] can be partitioned in two subsets of equal sum , otherwise false ; Calculate sum of all elements ; Initialize the part array as 0 ; Fill the partition table in bottom up manner ; the element to be included in the sum cannot be greater than the sum ; check if sum - arr [ i ] could be formed from a subset using elements before index i ; Drive code ; Function call\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def findPartiion ( arr , n ) :\\n\\tSum = 0\\n\\tfor i in range ( n ) :\\n\\t\\tSum += arr [ i ]\\n\\tif ( Sum % 2 != 0 ) :\\n\\t\\treturn 0\\n\\tpart = [ 0 ] * ( ( Sum \\/\\/ 2 ) + 1 )\\n\\tfor i in range ( ( Sum \\/\\/ 2 ) + 1 ) :\\n\\t\\tpart [ i ] = 0\\n\\tfor i in range ( n ) :\\n\\t\\tfor j in range ( Sum \\/\\/ 2 , arr [ i ] - 1 , - 1 ) :\\n\\t\\t\\tif ( part [ j - arr [ i ] ] == 1 or j == arr [ i ] ) :\\n\\t\\t\\t\\tpart [ j ] = 1\\n\\treturn part [ Sum \\/\\/ 2 ]\\narr = [ 1 , 3 , 3 , 2 , 3 , 2 ]\\nn = len ( arr )\\nif ( findPartiion ( arr , n ) == 1 ) :\\n\\tprint ( \\\" Can ▁ be ▁ divided ▁ into ▁ two ▁ subsets ▁ of ▁ equal ▁ sum \\\" )\\nelse :\\n\\tprint ( \\\" Can ▁ not ▁ be ▁ divided ▁ into ▁ two ▁ subsets ▁ of ▁ equal ▁ sum \\\" )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Program for Volume and Surface Area of Cuboid | utility function ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function areaCuboid ( $ l , $ h , $ w ) { return ( $ l * $ h * $ w ) ; } function surfaceAreaCuboid ( $ l , $ h , $ w ) { return ( 2 * $ l * $ w + 2 * $ w * $ h + 2 * $ l * $ h ) ; } $ l = 1 ; $ h = 5 ; $ w = 7 ; echo \\\" Area ▁ = ▁ \\\" , areaCuboid ( $ l , $ h , $ w ) , \\\" \\n \\\" ; echo \\\" Total ▁ Surface ▁ Area ▁ = ▁ \\\" , surfaceAreaCuboid ( $ l , $ h , $ w ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Find the Missing Number | ; getMissingNo takes array and size of array as arguments ; program to test above function\\\"\\nSolution in C:\",\"targets\":\"#include \\nint getMissingNo ( int a [ ] , int n ) { int i , total ; total = ( n + 1 ) * ( n + 2 ) \\/ 2 ; for ( i = 0 ; i < n ; i ++ ) total -= a [ i ] ; return total ; } int main ( ) { int a [ ] = { 1 , 2 , 4 , 5 , 6 } ; int miss = getMissingNo ( a , 5 ) ; printf ( \\\" % d \\\" , miss ) ; getchar ( ) ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Factorial of a number without using multiplication | Function to calculate factorial of the number without using multiplication operator ; variable to store the final factorial ; Outer loop ; Inner loop ; Input ; Function calling\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function factorialWithoutMul ( N ) { let ans = N ; for ( let i = N - 1 ; i > 0 ; i -- ) { let sum = 0 ; for ( let j = 0 ; j < i ; j ++ ) sum += ans ; ans = sum ; } return ans ; } let N = 5 ; document . write ( factorialWithoutMul ( N ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Sort the matrix row | Java implementation to sort the matrix row - wise and column - wise ; function to sort each row of the matrix ; sorting row number ' i ' ; function to find transpose of the matrix ; swapping element at index ( i , j ) by element at index ( j , i ) ; function to sort the matrix row - wise and column - wise ; sort rows of mat [ ] [ ] ; get transpose of mat [ ] [ ] ; again sort rows of mat [ ] [ ] ; again get transpose of mat [ ] [ ] ; function to print the matrix ; Driver code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . Arrays ; class GFG { static final int MAX_SIZE = 10 ; static void sortByRow ( int mat [ ] [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) Arrays . sort ( mat [ i ] ) ; } static void transpose ( int mat [ ] [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) { int temp = mat [ i ] [ j ] ; mat [ i ] [ j ] = mat [ j ] [ i ] ; mat [ j ] [ i ] = temp ; } } static void sortMatRowAndColWise ( int mat [ ] [ ] , int n ) { sortByRow ( mat , n ) ; transpose ( mat , n ) ; sortByRow ( mat , n ) ; transpose ( mat , n ) ; } static void printMat ( int mat [ ] [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) System . out . print ( mat [ i ] [ j ] + \\\" ▁ \\\" ) ; System . out . println ( ) ; } } public static void main ( String [ ] args ) { int mat [ ] [ ] = { { 4 , 1 , 3 } , { 9 , 6 , 8 } , { 5 , 2 , 7 } } ; int n = 3 ; System . out . print ( \\\"Original Matrix:\\n\\\"); printMat ( mat , n ) ; sortMatRowAndColWise ( mat , n ) ; System . out . print ( \\\" Matrix After Sorting : \\\"); printMat ( mat , n ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"Count smaller elements on right side | ; An AVL tree node ; size of the tree rooted with this node ; A utility function to get maximum of two integers ; A utility function to get height of the tree rooted with N ; A utility function to size of the tree of rooted with N ; A utility function to get maximum of two integers ; Helper function that allocates a new node with the given key and NULL left and right pointers . ; new node is initially added at leaf ; A utility function to right rotate subtree rooted with y ; Perform rotation ; Update heights ; Update sizes ; Return new root ; A utility function to left rotate subtree rooted with x ; Perform rotation ; Update heights ; Update sizes ; Return new root ; Get Balance factor of node N ; Inserts a new key to the tree rotted with node . Also , updates * count to contain count of smaller elements for the new key ; 1. Perform the normal BST rotation ; UPDATE COUNT OF SMALLER ELEMENTS FOR KEY ; 2. Update height and size of this ancestor node ; 3. Get the balance factor of this ancestor node to check whether this node became unbalanced ; Left Left Case ; Right Right Case ; Left Right Case ; Right Left Case ; return the ( unchanged ) node pointer ; The following function updates the countSmaller array to contain count of smaller elements on right side . ; initialize all the counts in countSmaller array as 0 ; Starting from rightmost element , insert all elements one by one in an AVL tree and get the count of smaller elements ; Utility function that prints out an array on a line ; Driver program to test above functions\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#include \\nstruct node { int key ; struct node * left ; struct node * right ; int height ; int size ; } ; int max ( int a , int b ) ; int height ( struct node * N ) { if ( N == NULL ) return 0 ; return N -> height ; } int size ( struct node * N ) { if ( N == NULL ) return 0 ; return N -> size ; } int max ( int a , int b ) { return ( a > b ) ? a : b ; } struct node * newNode ( int key ) { struct node * node = ( struct node * ) malloc ( sizeof ( struct node ) ) ; node -> key = key ; node -> left = NULL ; node -> right = NULL ; node -> height = 1 ; node -> size = 1 ; return ( node ) ; } struct node * rightRotate ( struct node * y ) { struct node * x = y -> left ; struct node * T2 = x -> right ; x -> right = y ; y -> left = T2 ; y -> height = max ( height ( y -> left ) , height ( y -> right ) ) + 1 ; x -> height = max ( height ( x -> left ) , height ( x -> right ) ) + 1 ; y -> size = size ( y -> left ) + size ( y -> right ) + 1 ; x -> size = size ( x -> left ) + size ( x -> right ) + 1 ; return x ; } struct node * leftRotate ( struct node * x ) { struct node * y = x -> right ; struct node * T2 = y -> left ; y -> left = x ; x -> right = T2 ; x -> height = max ( height ( x -> left ) , height ( x -> right ) ) + 1 ; y -> height = max ( height ( y -> left ) , height ( y -> right ) ) + 1 ; x -> size = size ( x -> left ) + size ( x -> right ) + 1 ; y -> size = size ( y -> left ) + size ( y -> right ) + 1 ; return y ; } int getBalance ( struct node * N ) { if ( N == NULL ) return 0 ; return height ( N -> left ) - height ( N -> right ) ; } struct node * insert ( struct node * node , int key , int * count ) { if ( node == NULL ) return ( newNode ( key ) ) ; if ( key < node -> key ) node -> left = insert ( node -> left , key , count ) ; else { node -> right = insert ( node -> right , key , count ) ; * count = * count + size ( node -> left ) + 1 ; } node -> height = max ( height ( node -> left ) , height ( node -> right ) ) + 1 ; node -> size = size ( node -> left ) + size ( node -> right ) + 1 ;...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"Permutation Coefficient | A O ( n ) solution that uses table fact [ ] to calculate the Permutation Coefficient ; Returns value of Permutation Coefficient P ( n , k ) ; base case ; Calculate value factorials up to n ; P ( n , k ) = n ! \\/ ( n - k ) ! ; Driver Code\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint permutationCoeff ( int n , int k ) { int fact [ n + 1 ] ; fact [ 0 ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) fact [ i ] = i * fact [ i - 1 ] ; return fact [ n ] \\/ fact [ n - k ] ; } int main ( ) { int n = 10 , k = 2 ; printf ( \\\" Value ▁ of ▁ P ( % d , ▁ % d ) ▁ is ▁ % d ▁ \\\" , n , k , permutationCoeff ( n , k ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Program to find whether a given number is power of 2 | C # program for above approach ; Function which checks whether a number is a power of 2 ; Base cases '1' is the only odd number which is a power of 2 ( 2 ^ 0 ) ; All other odd numbers are not powers of 2 ; Recursive function call ; Driver code ; True ; False\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static bool powerOf2 ( int n ) { if ( n == 1 ) return true ; else if ( n % 2 != 0 n == 0 ) return false ; return powerOf2 ( n \\/ 2 ) ; } static void Main ( ) { int n = 64 ; int m = 12 ; if ( powerOf2 ( n ) ) { Console . Write ( \\\" True \\\" + \\\" \\n \\\" ) ; } else { Console . Write ( \\\" False \\\" + \\\" \\n \\\" ) ; } if ( powerOf2 ( m ) ) { Console . Write ( \\\" True \\\" ) ; } else { Console . Write ( \\\" False \\\" ) ; } } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Count of elements to be inserted to make Array sum twice the XOR of Array | Function to find the minimum number of elements that need to be inserted such that the sum of the elements of the array is twice the XOR of the array ; Variable to store the Xor of all the elements ; Variable to store the sum of all elements ; Loop to find the Xor and the sum of the array ; If sum = 2 * Xor ; No need to insert more elements ; We insert one more element which is Sum ; We insert two more elements Sum + Xor and Xor . ; Print the number of elements inserted in the array ; Print the elements that are inserted in the array ; Driver code\\\"\\nSolution in Python:\",\"targets\":\"def insert_element ( a , n ) :\\n\\tXor = 0\\n\\tSum = 0\\n\\tfor i in range ( n ) :\\n\\t\\tXor ^= a [ i ]\\n\\t\\tSum += a [ i ]\\n\\tif ( Sum == 2 * Xor ) :\\n\\t\\tprint ( 0 )\\n\\t\\treturn\\n\\tif ( Xor == 0 ) :\\n\\t\\tprint ( 1 )\\n\\t\\tprint ( Sum )\\n\\t\\treturn\\n\\tnum1 = Sum + Xor\\n\\tnum2 = Xor\\n\\tprint ( 2 )\\n\\tprint ( num1 , num2 )\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\ta = [ 1 , 2 , 3 ]\\n\\tn = len ( a )\\n\\tinsert_element ( a , n )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Program to construct DFA for Regular Expression C ( A + B ) + | Function to find whether the given String is Accepted by the DFA ; If n <= 1 , then print No ; To count the matched characters ; Check if the first character is C ; Traverse the rest of String ; If character is A or B , increment count by 1 ; If the first character is not C , print - 1 ; If all characters matches ; Driver Code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function DFA ( str , N ) { if ( N <= 1 ) { document . write ( \\\" \\\" ) ; return ; } let count = 0 ; if ( str [ 0 ] == ' ' ) { count ++ ; for ( let i = 1 ; i < N ; i ++ ) { if ( str [ i ] == ' ' str [ i ] == ' ' ) count ++ ; else break ; } } else { document . write ( \\\" \\\" ) ; return ; } if ( count == N ) document . write ( \\\" \\\" ) ; else document . write ( \\\" \\\" ) ; } let str = \\\" \\\" ; let N = str . length ; DFA ( str , N ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Check if frequency of each element in given array is unique or not | Java code for the above approach ; Function to check whether the frequency of elements in array is unique or not . ; Freq map will store the frequency of each element of the array ; Store the frequency of each element from the array ; Check whether frequency of any two or more elements are same or not . If yes , return false ; Return true if each frequency is unique ; Driver Code ; Given array arr [ ] ; Function call ; Print the result\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { static boolean checkUniqueFrequency ( int arr [ ] , int n ) { HashMap < Integer , Integer > freq = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( freq . containsKey ( arr [ i ] ) ) { freq . put ( arr [ i ] , freq . get ( arr [ i ] ) + 1 ) ; } else { freq . put ( arr [ i ] , 1 ) ; } } HashSet < Integer > uniqueFreq = new HashSet < Integer > ( ) ; for ( Map . Entry < Integer , Integer > i : freq . entrySet ( ) ) { if ( uniqueFreq . contains ( i . getValue ( ) ) ) return false ; else uniqueFreq . add ( i . getValue ( ) ) ; } return true ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 , 2 , 5 , 5 } ; int n = arr . length ; boolean res = checkUniqueFrequency ( arr , n ) ; if ( res ) System . out . print ( \\\" Yes \\\" + \\\"\\n\\\"); else System . out . print ( \\\" No \\\" + \\\"\\n\\\"); } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"Finite Automata algorithm for Pattern Searching | C program for Finite Automata Pattern searching Algorithm ; If the character c is same as next character in pattern , then simply increment state ; ns stores the result which is next state ; ns finally contains the longest prefix which is also suffix in \\\" pat [ 0 . . state - 1 ] c \\\" Start from the largest possible value and stop when you find a prefix which is also suffix ; This function builds the TF table which represents4 Finite Automata for a given pattern ; Prints all occurrences of pat in txt ; Process txt over FA . ; Driver program to test above function\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#include \\n#define NO_OF_CHARS 256\\nint getNextState ( char * pat , int M , int state , int x ) { if ( state < M && x == pat [ state ] ) return state + 1 ; int ns , i ; for ( ns = state ; ns > 0 ; ns -- ) { if ( pat [ ns - 1 ] == x ) { for ( i = 0 ; i < ns - 1 ; i ++ ) if ( pat [ i ] != pat [ state - ns + 1 + i ] ) break ; if ( i == ns - 1 ) return ns ; } } return 0 ; } void computeTF ( char * pat , int M , int TF [ ] [ NO_OF_CHARS ] ) { int state , x ; for ( state = 0 ; state <= M ; ++ state ) for ( x = 0 ; x < NO_OF_CHARS ; ++ x ) TF [ state ] [ x ] = getNextState ( pat , M , state , x ) ; } void search ( char * pat , char * txt ) { int M = strlen ( pat ) ; int N = strlen ( txt ) ; int TF [ M + 1 ] [ NO_OF_CHARS ] ; computeTF ( pat , M , TF ) ; int i , state = 0 ; for ( i = 0 ; i < N ; i ++ ) { state = TF [ state ] [ txt [ i ] ] ; if ( state == M ) printf ( \\\" Pattern found at index % d \\\" , i - M + 1 ) ; } } int main ( ) { char * txt = \\\" AABAACAADAABAAABAA \\\" ; char * pat = \\\" AABA \\\" ; search ( pat , txt ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Check if an array of pairs can be sorted by swapping pairs with different first elements | java program for the above approach ; Function to check if an array is sorted or not ; Traverse the array arr [ ] ; Return true ; Function to check if it is possible to sort the array w . r . t . first element ; Stores the ID of the first element ; Traverse the array arr [ ] ; If arr [ i ] . second is not equal to that of the group ; If array is sorted ; Driver Code\\\"\\nSolution in Java:\",\"targets\":\"import java . io . * ; import java . lang . * ; import java . util . * ; public class GFG { static boolean isSorted ( int [ ] [ ] arr , int N ) { for ( int i = 1 ; i < N ; i ++ ) { if ( arr [ i ] [ 0 ] > arr [ i - 1 ] [ 0 ] ) { return false ; } } return true ; } static String isPossibleToSort ( int [ ] [ ] arr , int N ) { int group = arr [ 0 ] [ 1 ] ; for ( int i = 1 ; i < N ; i ++ ) { if ( arr [ i ] [ 1 ] != group ) { return \\\" Yes \\\" ; } } if ( isSorted ( arr , N ) ) { return \\\" Yes \\\" ; } else { return \\\" No \\\" ; } } public static void main ( String [ ] args ) { int arr [ ] [ ] = { { 340000 , 2 } , { 45000 , 1 } , { 30000 , 2 } , { 50000 , 4 } } ; int N = arr . length ; System . out . print ( isPossibleToSort ( arr , N ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Count ways to reach the nth stair using step 1 , 2 or 3 | Program to find n - th stair using step size 1 or 2 or 3. ; A recursive function used by countWays ; Driver function\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . lang . * ; import java . util . * ; public class GfG { public static int countWays ( int n ) { int [ ] res = new int [ n + 1 ] ; res [ 0 ] = 1 ; res [ 1 ] = 1 ; res [ 2 ] = 2 ; for ( int i = 3 ; i <= n ; i ++ ) res [ i ] = res [ i - 1 ] + res [ i - 2 ] + res [ i - 3 ] ; return res [ n ] ; } public static void main ( String argc [ ] ) { int n = 4 ; System . out . println ( countWays ( n ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Count of integral coordinates that lies inside a Square | C ++ program for the above approach ; Function to calculate the integral points inside a square ; Driver Code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; void countIntgralPoints ( int x1 , int y1 , int x2 , int y2 ) { cout << ( y2 - y1 - 1 ) * ( x2 - x1 - 1 ) ; } int main ( ) { int x1 = 1 , y1 = 1 ; int x2 = 4 , y2 = 4 ; countIntgralPoints ( x1 , y1 , x2 , y2 ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Largest Even and Odd N | C # implementation of the above approach ; Function to print the largest N - digit even and odd numbers of base B ; Initialise the Number ; If Base B is even , then B ^ n will give largest Even number of N + 1 digit ; To get even number of N digit subtract 2 from B ^ n ; To get odd number of N digit subtract 1 from B ^ n ; If Base B is odd , then B ^ n will give largest Odd number of N + 1 digit ; To get even number of N digit subtract 1 from B ^ n ; To get odd number of N digit subtract 2 from B ^ n ; Driver 's Code ; Function to find the numbers\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static void findNumbers ( int n , int b ) { double even = 0 , odd = 0 ; if ( b % 2 == 0 ) { even = Math . Pow ( b , n ) - 2 ; odd = Math . Pow ( b , n ) - 1 ; } else { even = Math . Pow ( b , n ) - 1 ; odd = Math . Pow ( b , n ) - 2 ; } Console . WriteLine ( \\\" Even ▁ Number ▁ = ▁ \\\" + ( int ) even ) ; Console . Write ( \\\" Odd ▁ Number ▁ = ▁ \\\" + ( int ) odd ) ; } public static void Main ( String [ ] args ) { int N = 2 , B = 5 ; findNumbers ( N , B ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Pell Number | Iterative Pell Number Series in C ; calculate nth pell number ; driver function\\\"\\nSolution in C:\",\"targets\":\"#include \\nint pell ( int n ) { if ( n <= 2 ) return n ; int a = 1 ; int b = 2 ; int c , i ; for ( i = 3 ; i <= n ; i ++ ) { c = 2 * b + a ; a = b ; b = c ; } return b ; } int main ( ) { int n = 4 ; printf ( \\\" % d \\\" , pell ( n ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Print path from root to all nodes in a Complete Binary Tree | Java program to print path from root to all nodes in a complete binary tree . ; Function to print path of all the nodes nth node represent as given node kth node represents as left and right node ; base condition if kth node value is greater then nth node then its means kth node is not valid so we not store it into the res simply we just return ; Storing node into res ; Print the path from root to node ; store left path of a tree So for left we will go node ( kThNode * 2 ) ; right path of a tree and for right we will go node ( kThNode * 2 + 1 ) ; Function to print path from root to all of the nodes ; res is for store the path from root to particulate node ; Print path from root to all node . third argument 1 because of we have to consider root node is 1 ; Driver Code ; Given Node ; Print path from root to all node .\\\"\\nSolution in Java:\",\"targets\":\"import java . util . * ; class GFG { static void printPath ( Vector < Integer > res , int nThNode , int kThNode ) { if ( kThNode > nThNode ) return ; res . add ( kThNode ) ; for ( int i = 0 ; i < res . size ( ) ; i ++ ) System . out . print ( res . get ( i ) + \\\" ▁ \\\" ) ; System . out . print ( \\\"\\n\\\"); printPath ( res , nThNode , kThNode * 2 ) ; printPath ( res , nThNode , kThNode * 2 + 1 ) ; res . remove ( res . size ( ) - 1 ) ; } static void printPathToCoverAllNodeUtil ( int nThNode ) { Vector < Integer > res = new Vector < Integer > ( ) ; printPath ( res , nThNode , 1 ) ; } public static void main ( String args [ ] ) { int nThNode = 7 ; printPathToCoverAllNodeUtil ( nThNode ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Check if array contains contiguous integers with duplicates allowed | Sorting based C ++ implementation to check whether the array contains a set of contiguous integers ; function to check whether the array contains a set of contiguous integers ; Sort the array ; After sorting , check if current element is either same as previous or is one more . ; Driver program to test above\\\"\\nSolution in C:\",\"targets\":\"#include \\nusing namespace std ; bool areElementsContiguous ( int arr [ ] , int n ) { sort ( arr , arr + n ) ; for ( int i = 1 ; i < n ; i ++ ) if ( arr [ i ] - arr [ i - 1 ] > 1 ) return false ; return true ; } int main ( ) { int arr [ ] = { 5 , 2 , 3 , 6 , 4 , 4 , 6 , 6 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; if ( areElementsContiguous ( arr , n ) ) cout << \\\" Yes \\\" ; else cout << \\\" No \\\" ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Sum of indices of Characters removed to obtain an Empty String based on given conditions | Java program to implement the above approach ; Function to add index of the deleted character ; If index is beyond the range ; Insert the index of the deleted characeter ; Search over the subtrees to find the desired index ; Function to return count of deleted indices which are to the left of the current index ; Function to generate the sum of indices ; Stores the original index of the characters in sorted order of key ; Traverse the map ; Extract smallest index of smallest character ; Delete the character from the map if it has no remaining occurrence ; Stores the original index ; Count of elements removed to the left of current character ; Current index of the current character ; For 1 - based indexing ; Insert the deleted index in the segment tree ; Final answer ; Driver Code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void add_seg ( int seg [ ] , int start , int end , int current , int index ) { if ( index > end index < start ) return ; if ( start == end ) { seg [ current ] = 1 ; return ; } int mid = ( start + end ) \\/ 2 ; add_seg ( seg , start , mid , 2 * current + 1 , index ) ; add_seg ( seg , mid + 1 , end , 2 * current + 2 , index ) ; seg [ current ] = seg [ 2 * current + 1 ] + seg [ 2 * current + 2 ] ; } static int deleted ( int seg [ ] , int l , int r , int start , int end , int current ) { if ( end < l start > r ) return 0 ; if ( start >= l && end <= r ) return seg [ current ] ; int mid = ( start + end ) \\/ 2 ; return deleted ( seg , l , r , start , mid , 2 * current + 1 ) + deleted ( seg , l , r , mid + 1 , end , 2 * current + 2 ) ; } static void sumOfIndices ( String s ) { int N = s . length ( ) ; int x = ( int ) ( Math . ceil ( Math . log ( N ) \\/ Math . log ( 2 ) ) ) ; int seg_size = 2 * ( int ) Math . pow ( 2 , x ) - 1 ; int segment [ ] = new int [ seg_size ] ; int count = 0 ; TreeMap < Integer , ArrayDeque < Integer > > fre = new TreeMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int key = ( int ) ( s . charAt ( i ) ) ; ArrayDeque < Integer > que = fre . getOrDefault ( key , new ArrayDeque < > ( ) ) ; que . addLast ( i ) ; fre . put ( key , que ) ; } while ( ! fre . isEmpty ( ) ) { int it = fre . firstKey ( ) ; if ( fre . get ( it ) . size ( ) == 0 ) fre . remove ( it ) ; else { ArrayDeque < Integer > que = fre . get ( it ) ; int original_index = que . getFirst ( ) ; int curr_index = deleted ( segment , 0 , original_index - 1 , 0 , N - 1 , 0 ) ; int new_index = original_index - curr_index ; count += new_index + 1 ; add_seg ( segment , 0 , N - 1 , 0 , original_index ) ; que . removeFirst ( ) ; fre . put ( it , que ) ; } } System . out . println ( count ) ; } public static void main ( String [ ] args ) { String s = \\\" geeksforgeeks \\\" ; sumOfIndices ( s ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Maximize sum by choosing elements from different section of a matrix | C # program for the above approach ; Function to find the maximum value ; Dp table ; Fill the dp in bottom up manner ; Maximum of the three sections ; Maximum of the first section ; Maximum of the second section ; Maximum of the third section ; If we choose element from section 1 , we cannot have selection from same section in adjacent rows ; Print the maximum sum ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static int n = 6 , m = 6 ; static void maxSum ( long [ , ] arr ) { long [ , ] dp = new long [ n + 1 , 3 ] ; for ( int i = 0 ; i < n ; i ++ ) { long m1 = 0 , m2 = 0 , m3 = 0 ; for ( int j = 0 ; j < m ; j ++ ) { if ( ( j \\/ ( m \\/ 3 ) ) == 0 ) { m1 = Math . Max ( m1 , arr [ i , j ] ) ; } else if ( ( j \\/ ( m \\/ 3 ) ) == 1 ) { m2 = Math . Max ( m2 , arr [ i , j ] ) ; } else if ( ( j \\/ ( m \\/ 3 ) ) == 2 ) { m3 = Math . Max ( m3 , arr [ i , j ] ) ; } } dp [ i + 1 , 0 ] = Math . Max ( dp [ i , 1 ] , dp [ i , 2 ] ) + m1 ; dp [ i + 1 , 1 ] = Math . Max ( dp [ i , 0 ] , dp [ i , 2 ] ) + m2 ; dp [ i + 1 , 2 ] = Math . Max ( dp [ i , 1 ] , dp [ i , 0 ] ) + m3 ; } Console . Write ( Math . Max ( Math . Max ( dp [ n , 0 ] , dp [ n , 1 ] ) , dp [ n , 2 ] ) + \\\" \\n \\\" ) ; } public static void Main ( String [ ] args ) { long [ , ] arr = { { 1 , 3 , 5 , 2 , 4 , 6 } , { 6 , 4 , 5 , 1 , 3 , 2 } , { 1 , 3 , 5 , 2 , 4 , 6 } , { 6 , 4 , 5 , 1 , 3 , 2 } , { 6 , 4 , 5 , 1 , 3 , 2 } , { 1 , 3 , 5 , 2 , 4 , 6 } } ; maxSum ( arr ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Count composite fibonacci numbers from given array | Function to find all Fibonacci numbers up to Max ; Store all Fibonacci numbers upto Max ; Stores previous element of Fibonacci sequence ; Stores previous element of Fibonacci sequence ; Insert prev into hashmap ; Insert all the Fibonacci numbers up to Max ; Insert curr into hashmap ; Stores curr into temp ; Update curr ; Update prev ; Function to find all Composite numbers up to Max ; isPrime [ i ] : Stores if i is a prime number or not ; Calculate all prime numbers up to Max using Sieve of Eratosthenes ; If P is a prime number ; Set all multiple of P as non - prime ; Update isPrime ; Function to find the numbers which is both a composite and Fibonacci number ; Stores the largest element of the array ; Traverse the array arr [ ] ; Update Max ; isPrim [ i ] check i is a prime number or not ; Stores all the Fibonacci numbers ; Traverse the array arr [ ] ; current element is not a composite number ; If current element is a Fibonacci and composite number ; Print current element ; Driver Code\\\"\\nSolution in Javascript:\",\"targets\":\"function createhashmap ( Max ) { var hashmap = new Set ( ) ; var curr = 1 ; var prev = 0 ; hashmap . add ( prev ) ; while ( curr <= Max ) { hashmap . add ( curr ) ; var temp = curr ; curr = curr + prev ; prev = temp ; } return hashmap ; } function SieveOfEratosthenes ( Max ) { var isPrime = Array ( Max + 1 ) . fill ( true ) ; isPrime [ 0 ] = false ; isPrime [ 1 ] = false ; for ( var p = 2 ; p * p <= Max ; p ++ ) { if ( isPrime [ p ] ) { for ( var i = p * p ; i <= Max ; i += p ) { isPrime [ i ] = false ; } } } return isPrime ; } function cntFibonacciPrime ( arr , N ) { var Max = arr [ 0 ] ; for ( var i = 1 ; i < N ; i ++ ) { Max = Math . max ( Max , arr [ i ] ) ; } var isPrime = SieveOfEratosthenes ( Max ) ; var hashmap = createhashmap ( Max ) ; for ( var i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 1 ) continue ; if ( hashmap . has ( arr [ i ] ) && ! isPrime [ arr [ i ] ] ) { document . write ( arr [ i ] + \\\" \\\" ) ; } } } var arr = [ 13 , 55 , 7 , 3 , 5 , 21 , 233 , 144 , 89 ] ; var N = arr . length ; cntFibonacciPrime ( arr , N ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Smallest submatrix required to be removed such that sum of the remaining matrix is divisible by K | Python3 program to implement the above approach ; Function to find the length of the smallest subarray to be removed such that sum of elements is equal to S % K ; Remainder when total_sum is divided by K ; Stores curr_remainder and the most recent index at which curr_remainder has occured ; Stores required answer ; Add current element to curr_sum and take mod ; Update current remainder index ; If mod already exists in map the subarray exists ; Update res ; If not possible ; Return the result ; Function to find the smallest submatrix rqured to be deleted to make the sum of the matrix divisible by K ; Stores the sum of element of the matrix ; Traverse the matrix mat [ ] [ ] ; Update S ; Stores smallest area need to be deleted to get sum divisible by K ; Stores leftmost column of each matrix ; Stores rightmost column of each matrix ; Stores number of coulmns deleted of a matrix ; Store area of the deleted matrix ; prefixRowSum [ i ] : Store sum of sub matrix whose topmost left and bottommost right position is ( 0 , left ) ( i , right ) ; Iterate over all possible values of ( left , right ) ; Initialize all possible values of prefixRowSum [ ] to 0 ; Traverse each row from left to right column ; Update row_sum [ i ] ; Update width ; If no submatrix of the length ( right - left + 1 ) found to get the required output ; Update area ; If area is less than min_area ; Update min_area ; Driver Code ; Stores number of rows in the matrix ; Stores number of column in the matrix\\\"\\nSolution in Python:\",\"targets\":\"import sys\\ndef removeSmallestSubarray ( arr , S , n , k ) :\\n\\ttarget_remainder = S % k\\n\\tmap1 = { }\\n\\tmap1 [ 0 ] = - 1\\n\\tcurr_remainder = 0\\n\\tres = sys . maxsize\\n\\tfor i in range ( n ) :\\n\\t\\tcurr_remainder = ( curr_remainder + arr [ i ] + k ) % k\\n\\t\\tmap1 [ curr_remainder ] = i\\n\\t\\tmod = ( curr_remainder - target_remainder + k ) % k\\n\\t\\tif ( mod in map1 ) :\\n\\t\\t\\tres = min ( res , i - map1 [ mod ] )\\n\\tif ( res == sys . maxsize or res == n ) :\\n\\t\\tres = - 1\\n\\treturn res\\ndef smstSubmatDeleted ( mat , N , M , K ) :\\n\\tS = 0\\n\\tfor i in range ( N ) :\\n\\t\\tfor j in range ( M ) :\\n\\t\\t\\tS += mat [ i ] [ j ]\\n\\tmin_area = N * M\\n\\tleft = 0\\n\\tright = 0\\n\\twidth = 0\\n\\tarea = 0\\n\\tprefixRowSm = [ 0 ] * N\\n\\tfor left in range ( M ) :\\n\\t\\tprefixRowSum = [ 0 ] * N\\n\\t\\tfor right in range ( left , M ) :\\n\\t\\t\\tfor i in range ( N ) :\\n\\t\\t\\t\\tprefixRowSum [ i ] += mat [ i ] [ right ]\\n\\t\\t\\twidth = removeSmallestSubarray ( prefixRowSum , S , N , K )\\n\\t\\t\\tif ( width != - 1 ) :\\n\\t\\t\\t\\tarea = ( right - left + 1 ) * ( width )\\n\\t\\t\\t\\tif ( area < min_area ) :\\n\\t\\t\\t\\t\\tmin_area = area\\n\\treturn min_area\\nif __name__ == ' _ _ main _ _ ' :\\n\\tmat = [ [ 6 , 2 , 6 ] , [ 3 , 2 , 8 ] , [ 2 , 5 , 3 ] ]\\n\\tK = 3\\n\\tN = len ( mat )\\n\\tM = len ( mat [ 0 ] )\\n\\tprint ( smstSubmatDeleted ( mat , N , M , K ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Bitwise Operators in C \\/ C ++ |\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int main ( ) { int x = 2 , y = 5 ; ( x & y ) ? cout << \\\" True ▁ \\\" : cout << \\\" False ▁ \\\" ; ( x && y ) ? cout << \\\" True ▁ \\\" : cout << \\\" False ▁ \\\" ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Maximum Tip Calculator | Function that finds the maximum tips from the given arrays as per the given conditions ; Base Condition ; If both have non - zero count then return max element from both array ; Traverse first array , as y count has become 0 ; Traverse 2 nd array , as x count has become 0 ; Drive Code ; Function Call\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function maximumTip ( arr1 , arr2 , n , x , y ) { if ( n == 0 ) return 0 ; if ( x != 0 && y != 0 ) return Math . max ( arr1 [ n - 1 ] + maximumTip ( arr1 , arr2 , n - 1 , x - 1 , y ) , arr2 [ n - 1 ] + maximumTip ( arr1 , arr2 , n - 1 , x , y - 1 ) ) ; if ( y == 0 ) return arr1 [ n - 1 ] + maximumTip ( arr1 , arr2 , n - 1 , x - 1 , y ) ; else return arr2 [ n - 1 ] + maximumTip ( arr1 , arr2 , n - 1 , x , y - 1 ) ; } let N = 5 ; let X = 3 ; let Y = 3 ; let A = [ 1 , 2 , 3 , 4 , 5 ] ; let B = [ 5 , 4 , 3 , 2 , 1 ] ; document . write ( maximumTip ( A , B , N , X , Y ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Check if any subarray can be made palindromic by replacing less than half of its elements | A Utility Function to check if a subarray can be palindromic by replacing less than half of the elements present in it ; Stores frequency of array elements ; Traverse the array ; Update frequency of each array element ; Iterator over the Map ; If frequency of any element exceeds 1 ; If no repetition is found ; Function to check and print if any subarray can be made palindromic by replacing less than half of its elements ; Driver Code ; Given array arr [ ] ; Size of array ; Function Call\\\"\\nSolution in Python:\",\"targets\":\"def isConsistingSubarrayUtil ( arr , n ) :\\n\\tmp = { } ;\\n\\tfor i in range ( n ) :\\n\\t\\tif arr [ i ] in mp :\\n\\t\\t\\tmp [ arr [ i ] ] += 1 ;\\n\\t\\telse :\\n\\t\\t\\tmp [ arr [ i ] ] = 1 ;\\n\\tfor it in mp :\\n\\t\\tif ( mp [ it ] > 1 ) :\\n\\t\\t\\treturn True ;\\n\\treturn False ;\\ndef isConsistingSubarray ( arr , N ) :\\n\\tif ( isConsistingSubarrayUtil ( arr , N ) ) :\\n\\t\\tprint ( \\\" Yes \\\" ) ;\\n\\telse :\\n\\t\\tprint ( \\\" No \\\" ) ;\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tarr = [ 1 , 2 , 3 , 4 , 5 , 1 ] ;\\n\\tN = len ( arr ) ;\\n\\tisConsistingSubarray ( arr , N ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Find n | function to solve the quadratic equation ; calculating the Nth term ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function term ( $ n ) { $ x = ( ( ( 1 ) + ( double ) sqrt ( 1 + ( 8 * $ n ) ) ) \\/ 2 ) ; return $ x ; } $ n = 5 ; echo ( ( int ) term ( $ n ) ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Partition problem | DP | A Dynamic Programming based Java program to partition problem ; Returns true if arr [ ] can be partitioned in two subsets of equal sum , otherwise false ; Calculate sum of all elements ; Initialze the part array as 0 ; Fill the partition table in bottom up manner ; The element to be included in the sum cannot be greater than the sum ; Check if sum - arr [ i ] could be formed from a subset using elements before index i ; Driver code ; Function call\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . io . * ; class GFG { public static boolean findPartiion ( int arr [ ] , int n ) { int sum = 0 ; int i , j ; for ( i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; if ( sum % 2 != 0 ) return false ; boolean [ ] part = new boolean [ sum \\/ 2 + 1 ] ; for ( i = 0 ; i <= sum \\/ 2 ; i ++ ) { part [ i ] = false ; } for ( i = 0 ; i < n ; i ++ ) { for ( j = sum \\/ 2 ; j >= arr [ i ] ; j -- ) { if ( part [ j - arr [ i ] ] == true j == arr [ i ] ) part [ j ] = true ; } } return part [ sum \\/ 2 ] ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 3 , 3 , 2 , 3 , 2 } ; int n = 6 ; if ( findPartiion ( arr , n ) == true ) System . out . println ( \\\" Can ▁ be ▁ divided ▁ into ▁ two ▁ \\\" + \\\" subsets ▁ of ▁ equal ▁ sum \\\" ) ; else System . out . println ( \\\" Can ▁ not ▁ be ▁ divided ▁ into ▁ \\\" + \\\" two ▁ subsets ▁ of ▁ equal ▁ sum \\\" ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Queries to find the last non | Maximum distinct characters possible ; To store the frequency of the characters ; Function to pre - calculate the frequency array ; Only the first character has frequency 1 till index 0 ; Starting from the second character of the string ; For every possible character ; Current character under consideration ; If it is equal to the character at the current index ; Function to return the frequency of the given character in the sub - string $str [ $l ... $r ] ; Function to return the last non - repeating character ; Starting from the last character ; Current character ; If frequency of the current character is 1 then return the character ; All the characters of the sub - string are repeating ; Driver code ; Pre - calculate the frequency array\\\"\\nSolution in php:\",\"targets\":\"< ? php $ MAX = 256 ; $ freq = array_fill ( 0 , 256 , array_fill ( 0 , 1000 , 0 ) ) ; function preCalculate ( $ str , $ n ) { global $ freq ; global $ MAX ; $ freq [ ord ( $ str [ 0 ] ) ] [ 0 ] = 1 ; for ( $ i = 1 ; $ i < $ n ; $ i ++ ) { $ ch = $ str [ $ i ] ; for ( $ j = 0 ; $ j < $ MAX ; $ j ++ ) { $ charToUpdate = chr ( $ j ) ; if ( $ charToUpdate == $ ch ) $ freq [ $ j ] [ $ i ] = $ freq [ $ j ] [ $ i - 1 ] + 1 ; else $ freq [ $ j ] [ $ i ] = $ freq [ $ j ] [ $ i - 1 ] ; } } } function getFrequency ( $ ch , $ l , $ r ) { global $ freq ; if ( $ l == 0 ) return $ freq [ ord ( $ ch ) ] [ $ r ] ; else return ( $ freq [ ord ( $ ch ) ] [ $ r ] - $ freq [ ord ( $ ch ) ] [ $ l - 1 ] ) ; } function lastNonRepeating ( $ str , $ n , $ l , $ r ) { for ( $ i = $ r ; $ i >= $ l ; $ i -- ) { $ ch = $ str [ $ i ] ; if ( getFrequency ( $ ch , $ l , $ r ) == 1 ) return $ ch ; } return \\\" - 1\\\" ; } $ str = \\\" GeeksForGeeks \\\" ; $ n = strlen ( $ str ) ; $ queries = array ( array ( 2 , 9 ) , array ( 2 , 3 ) , array ( 0 , 12 ) ) ; $ q = 3 ; preCalculate ( $ str , $ n ) ; for ( $ i = 0 ; $ i < $ q ; $ i ++ ) { echo ( lastNonRepeating ( $ str , $ n , $ queries [ $ i ] [ 0 ] , $ queries [ $ i ] [ 1 ] ) ) , \\\" \\n \\\" ; } ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Print N | Java program to print all N - bit binary ; Function to get the binary representation of the number N ; loop for each bit ; generate numbers in the range of ( 2 ^ N ) - 1 to 2 ^ ( N - 1 ) inclusive ; longest prefix check ; if counts of 1 is greater than counts of zero ; do sub - prefixes check ; Driver code ; Function call\\\"\\nSolution in Java:\",\"targets\":\"import java . io . * ; import java . util . * ; class GFG { static String getBinaryRep ( int N , int num_of_bits ) { String r = \\\" \\\" ; num_of_bits -- ; while ( num_of_bits >= 0 ) { if ( ( N & ( 1 << num_of_bits ) ) != 0 ) r += \\\"1\\\" ; else r += \\\"0\\\" ; num_of_bits -- ; } return r ; } static ArrayList < String > NBitBinary ( int N ) { ArrayList < String > r = new ArrayList < String > ( ) ; int first = 1 << ( N - 1 ) ; int last = first * 2 ; for ( int i = last - 1 ; i >= first ; -- i ) { int zero_cnt = 0 ; int one_cnt = 0 ; int t = i ; int num_of_bits = 0 ; while ( t > 0 ) { if ( ( t & 1 ) != 0 ) one_cnt ++ ; else zero_cnt ++ ; num_of_bits ++ ; t = t >> 1 ; } if ( one_cnt >= zero_cnt ) { boolean all_prefix_match = true ; int msk = ( 1 << num_of_bits ) - 2 ; int prefix_shift = 1 ; while ( msk > 0 ) { int prefix = ( msk & i ) >> prefix_shift ; int prefix_one_cnt = 0 ; int prefix_zero_cnt = 0 ; while ( prefix > 0 ) { if ( ( prefix & 1 ) != 0 ) prefix_one_cnt ++ ; else prefix_zero_cnt ++ ; prefix = prefix >> 1 ; } if ( prefix_zero_cnt > prefix_one_cnt ) { all_prefix_match = false ; break ; } prefix_shift ++ ; msk = msk & ( msk << 1 ) ; } if ( all_prefix_match ) { r . add ( getBinaryRep ( i , num_of_bits ) ) ; } } } return r ; } public static void main ( String [ ] args ) { int n = 4 ; ArrayList < String > results = NBitBinary ( n ) ; for ( int i = 0 ; i < results . size ( ) ; ++ i ) System . out . print ( results . get ( i ) + \\\" ▁ \\\" ) ; System . out . println ( ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Check if all array elements can be removed by the given operations | C # program to implement the above approach ; Function to check if it is possible to remove all array elements ; Condition if we can remove all elements from the array ; Driver Code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static void removeAll ( int [ ] arr , int n ) { if ( arr [ 0 ] < arr [ n - 1 ] ) Console . Write ( \\\" YES \\\" ) ; else Console . Write ( \\\" NO \\\" ) ; } public static void Main ( String [ ] args ) { int [ ] Arr = { 10 , 4 , 7 , 1 , 3 , 6 } ; int size = Arr . Length ; removeAll ( Arr , size ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Divide array into increasing and decreasing subsequence without changing the order | Function to print strictly increasing and strictly decreasing sequence if possible ; Arrays to store strictly increasing and decreasing sequence ; Initializing last element of both sequence ; Iterating through the array ; If current element can be appended to both the sequences ; If next element is greater than the current element Then append it to the strictly increasing array ; Otherwise append it to the strictly decreasing array ; If current element can be appended to the increasing sequence only ; If current element can be appended to the decreasing sequence only ; Else we can not make such sequences from the given array ; Print the required sequences ; Driver code\\\"\\nSolution in Python:\",\"targets\":\"def Find_Sequence ( array , n ) :\\n\\tinc_arr , dec_arr = [ ] , [ ]\\n\\tinc , dec = - 1 , 1e7\\n\\tfor i in range ( n ) :\\n\\t\\tif inc < array [ i ] < dec :\\n\\t\\t\\tif array [ i ] < array [ i + 1 ] :\\n\\t\\t\\t\\tinc = array [ i ]\\n\\t\\t\\t\\tinc_arr . append ( array [ i ] )\\n\\t\\t\\telse :\\n\\t\\t\\t\\tdec = array [ i ]\\n\\t\\t\\t\\tdec_arr . append ( array [ i ] )\\n\\t\\telif inc < array [ i ] :\\n\\t\\t\\tinc = array [ i ]\\n\\t\\t\\tinc_arr . append ( array [ i ] )\\n\\t\\telif dec > array [ i ] :\\n\\t\\t\\tdec = array [ i ]\\n\\t\\t\\tdec_arr . append ( array [ i ] )\\n\\t\\telse :\\n\\t\\t\\tprint ( ' - 1' )\\n\\t\\t\\tbreak\\n\\telse :\\n\\t\\tprint ( inc_arr , dec_arr )\\narr = [ 5 , 1 , 3 , 6 , 8 , 2 , 9 , 0 , 10 ]\\nn = len ( arr )\\nFind_Sequence ( arr , n )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Number of n digit stepping numbers | Space optimized solution | function that calculates the answer ; dp [ j ] stores count of i digit stepping numbers ending with digit j . ; To store result of length i - 1 before updating dp [ j ] for length i . ; if n is 1 then answer will be 10. ; Initialize values for count of digits equal to 1. ; Compute values for count of digits more than 1. ; If ending digit is 0 ; If ending digit is 9 ; For other digits . ; stores the final answer ; driver program to test the above function\\\"\\nSolution in Javascript:\",\"targets\":\"function answer ( n ) { var dp = Array ( 10 ) ; var prev = Array ( 10 ) ; if ( n == 1 ) return 10 ; for ( var j = 0 ; j <= 9 ; j ++ ) dp [ j ] = 1 ; for ( var i = 2 ; i <= n ; i ++ ) { for ( var j = 0 ; j <= 9 ; j ++ ) { prev [ j ] = dp [ j ] ; } for ( var j = 0 ; j <= 9 ; j ++ ) { if ( j == 0 ) dp [ j ] = prev [ j + 1 ] ; else if ( j == 9 ) dp [ j ] = prev [ j - 1 ] ; else dp [ j ] = prev [ j - 1 ] + prev [ j + 1 ] ; } } var sum = 0 ; for ( var j = 1 ; j <= 9 ; j ++ ) sum += dp [ j ] ; return sum ; } var n = 2 ; document . write ( answer ( n ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Tetranacci Numbers | Function to print the N - th tetranacci number ; base cases ; Driver code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def printTetra ( n ) :\\n\\tdp = [ 0 ] * ( n + 5 ) ;\\n\\tdp [ 0 ] = 0 ;\\n\\tdp [ 1 ] = 1 ;\\n\\tdp [ 2 ] = 1 ;\\n\\tdp [ 3 ] = 2 ;\\n\\tfor i in range ( 4 , n + 1 ) :\\n\\t\\tdp [ i ] = ( dp [ i - 1 ] + dp [ i - 2 ] + dp [ i - 3 ] + dp [ i - 4 ] ) ;\\n\\tprint ( dp [ n ] ) ;\\nn = 10 ;\\nprintTetra ( n ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Find distinct characters in distinct substrings of a string | Function to return the count of distinct characters in all the distinct sub - strings of the given string ; To store all the sub - strings ; To store the current sub - string ; To store the characters of the current sub - string ; If current sub - string hasn 't been stored before ; Insert it into the set ; Update the count of distinct characters ; Driver code\\\"\\nSolution in Javascript:\",\"targets\":\"function countTotalDistinct ( str ) { let cnt = 0 ; let items = new Set ( ) ; for ( let i = 0 ; i < str . length ; ++ i ) { let temp = \\\" \\\" ; let ans = new Set ( ) ; for ( let j = i ; j < str . length ; ++ j ) { temp = temp + str [ j ] ; ans . add ( str [ j ] ) ; if ( ! items . has ( temp ) ) { items . add ( temp ) ; cnt += ans . size ; } } } return cnt ; } let str = \\\" \\\" ; document . write ( countTotalDistinct ( str ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Program to Convert Radian to Degree | Function for convertion ; Driver Code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function Convert ( radian ) { let pi = 3.14159 ; return ( radian * ( 180 \\/ pi ) ) ; } let radian = 5.0 ; let degree = Convert ( radian ) ; document . write ( degree ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Minimum removals required to make a given array Bitonic | C # program to implement the above approach ; Function to coutnt minimum array elements required to be removed to make an array bitonic ; left [ i ] : Stores the length of LIS up to i - th index ; right [ i ] : Stores the length of decreasing subsequence over the range [ i , N ] ; Calculate the length of LIS up to i - th index ; Traverse the array upto i - th index ; If arr [ j ] is less than arr [ i ] ; Update left [ i ] ; Calculate the length of decreasing subsequence over the range [ i , N ] ; Traverse right [ ] array ; If arr [ i ] is greater than arr [ j ] ; Update right [ i ] ; Stores length of the longest bitonic array ; Traverse left [ ] and right [ ] array ; Update maxLen ; Function to print minimum removals required to make given array bitonic ; Driver Code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static void min_element_removal ( int [ ] arr , int N ) { int [ ] left = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) left [ i ] = 1 ; int [ ] right = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) right [ i ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { if ( arr [ j ] < arr [ i ] ) { left [ i ] = Math . Max ( left [ i ] , left [ j ] + 1 ) ; } } } for ( int i = N - 2 ; i >= 0 ; i -- ) { for ( int j = N - 1 ; j > i ; j -- ) { if ( arr [ i ] > arr [ j ] ) { right [ i ] = Math . Max ( right [ i ] , right [ j ] + 1 ) ; } } } int maxLen = 0 ; for ( int i = 1 ; i < N - 1 ; i ++ ) { maxLen = Math . Max ( maxLen , left [ i ] + right [ i ] - 1 ) ; } Console . WriteLine ( N - maxLen ) ; } static void makeBitonic ( int [ ] arr , int N ) { if ( N == 1 ) { Console . WriteLine ( \\\"0\\\" ) ; return ; } if ( N == 2 ) { if ( arr [ 0 ] != arr [ 1 ] ) Console . WriteLine ( \\\"0\\\" ) ; else Console . WriteLine ( \\\"1\\\" ) ; return ; } min_element_removal ( arr , N ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 1 , 1 , 5 , 6 , 2 , 3 , 1 } ; int N = arr . Length ; makeBitonic ( arr , N ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Median of two sorted arrays of same size | A Simple Merge based O ( n ) solution to find median of two sorted arrays ; This function returns median of ar1 [ ] and ar2 [ ] . Assumptions in this function : Both ar1 [ ] and ar2 [ ] are sorted arrays Both have n elements ; Since there are 2 n elements , median will be average of elements at index n - 1 and n in the array obtained after merging ar1 and ar2 ; Below is to handle case where all elements of ar1 [ ] are smaller than smallest ( or first ) element of ar2 [ ] ; Below is to handle case where all elements of ar2 [ ] are smaller than smallest ( or first ) element of ar1 [ ] ; equals sign because if two arrays have some common elements ; Store the prev median ; Store the prev median ; Driver program to test above function\\\"\\nSolution in C:\",\"targets\":\"#include \\nint getMedian ( int ar1 [ ] , int ar2 [ ] , int n ) { int i = 0 ; int j = 0 ; int count ; int m1 = -1 , m2 = -1 ; for ( count = 0 ; count <= n ; count ++ ) { if ( i == n ) { m1 = m2 ; m2 = ar2 [ 0 ] ; break ; } else if ( j == n ) { m1 = m2 ; m2 = ar1 [ 0 ] ; break ; } if ( ar1 [ i ] <= ar2 [ j ] ) { m1 = m2 ; m2 = ar1 [ i ] ; i ++ ; } else { m1 = m2 ; m2 = ar2 [ j ] ; j ++ ; } } return ( m1 + m2 ) \\/ 2 ; } int main ( ) { int ar1 [ ] = { 1 , 12 , 15 , 26 , 38 } ; int ar2 [ ] = { 2 , 13 , 17 , 30 , 45 } ; int n1 = sizeof ( ar1 ) \\/ sizeof ( ar1 [ 0 ] ) ; int n2 = sizeof ( ar2 ) \\/ sizeof ( ar2 [ 0 ] ) ; if ( n1 == n2 ) printf ( \\\" Median ▁ is ▁ % d \\\" , getMedian ( ar1 , ar2 , n1 ) ) ; else printf ( \\\" Doesn ' t ▁ work ▁ for ▁ arrays ▁ of ▁ unequal ▁ size \\\" ) ; getchar ( ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Arc length from given Angle | function to calculate arc length ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function arcLength ( $ diameter , $ angle ) { $ pi = 22.0 \\/ 7.0 ; $ arc ; if ( $ angle >= 360 ) { echo \\\" Angle ▁ cannot \\\" , \\\" ▁ be ▁ formed \\\" ; return 0 ; } else { $ arc = ( $ pi * $ diameter ) * ( $ angle \\/ 360.0 ) ; return $ arc ; } } $ diameter = 25.0 ; $ angle = 45.0 ; $ arc_len = arcLength ( $ diameter , $ angle ) ; echo ( $ arc_len ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Turn off the rightmost set bit | Set 2 | C ++ program to unset the rightmost set bit ; Unsets the rightmost set bit of n and returns the result ; Checking whether bit position is set or not ; If bit position is found set , we flip this bit by xoring given number and number with bit position set ; Driver code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; void FlipBits ( int n ) { for ( int bit = 0 ; bit < 32 ; bit ++ ) { if ( ( n >> bit ) & 1 ) { n = n ^ ( 1ll << bit ) ; break ; } } cout << \\\" The ▁ number ▁ after ▁ unsetting ▁ the \\\" ; cout << \\\" ▁ rightmost ▁ set ▁ bit ▁ \\\" << n ; } int main ( ) { int N = 12 ; FlipBits ( N ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Maximum size subset with given sum using Backtracking | Java Program to implement the above approach ; Initialise maximum possible length of subsequence ; Store elements to compare max_length with its size and change the value of max_length accordingly ; Store the elements of the longest subsequence ; Function to find the length of longest subsequence ; Update max_length ; Store the subsequence elements ; Recursively proceed with obtained sum ; poping elements from back of vector store ; if sum > 0 then we don 't required thatsubsequence so return and continue with earlier elements ; Sort the given array ; Traverse the array ; If max_length is already greater than or equal than remaining length ; Driver code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { static int max_length = 0 ; static Vector < Integer > store = new Vector < Integer > ( ) ; static Vector < Integer > ans = new Vector < Integer > ( ) ; static void find_max_length ( int [ ] arr , int index , int sum , int k ) { sum = sum + arr [ index ] ; store . add ( arr [ index ] ) ; if ( sum == k ) { if ( max_length < store . size ( ) ) { max_length = store . size ( ) ; ans = store ; } } for ( int i = index + 1 ; i < arr . length ; i ++ ) { if ( sum + arr [ i ] <= k ) { find_max_length ( arr , i , sum , k ) ; store . remove ( store . size ( ) - 1 ) ; } else return ; } return ; } static int longestSubsequence ( int [ ] arr , int n , int k ) { Arrays . sort ( arr ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( max_length >= n - i ) break ; store . clear ( ) ; find_max_length ( arr , i , 0 , k ) ; } return max_length ; } public static void main ( String [ ] args ) { int [ ] arr = { - 3 , 0 , 1 , 1 , 2 } ; int n = arr . length ; int k = 1 ; System . out . print ( longestSubsequence ( arr , n , k ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"K 'th Largest element in BST using constant extra space | helper function to create a new Node ; count variable to keep count of visited Nodes ; if right child is None ; first increment count and check if count = k ; otherwise move to the left child ; find inorder successor of current Node ; set left child of successor to the current Node ; move current to its right ; restoring the tree back to original binary search tree removing threaded links ; move current to its left child ; Driver Code ; Constructed binary tree is 4 \\/ \\\\ 2 7 \\/ \\\\ \\/ \\\\ 1 3 6 10\\\"\\nSolution in Python:\",\"targets\":\"class newNode :\\n\\tdef __init__ ( self , data ) :\\n\\t\\tself . data = data\\n\\t\\tself . right = self . left = None\\ndef KthLargestUsingMorrisTraversal ( root , k ) :\\n\\tcurr = root\\n\\tKlargest = None\\n\\tcount = 0\\n\\twhile ( curr != None ) :\\n\\t\\tif ( curr . right == None ) :\\n\\t\\t\\tcount += 1\\n\\t\\t\\tif ( count == k ) :\\n\\t\\t\\t\\tKlargest = curr\\n\\t\\t\\tcurr = curr . left\\n\\t\\telse :\\n\\t\\t\\tsucc = curr . right\\n\\t\\t\\twhile ( succ . left != None and succ . left != curr ) :\\n\\t\\t\\t\\tsucc = succ . left\\n\\t\\t\\tif ( succ . left == None ) :\\n\\t\\t\\t\\tsucc . left = curr\\n\\t\\t\\t\\tcurr = curr . right\\n\\t\\t\\telse :\\n\\t\\t\\t\\tsucc . left = None\\n\\t\\t\\t\\tcount += 1\\n\\t\\t\\t\\tif ( count == k ) :\\n\\t\\t\\t\\t\\tKlargest = curr\\n\\t\\t\\t\\tcurr = curr . left\\n\\treturn Klargest\\nif __name__ == ' _ _ main _ _ ' :\\n\\troot = newNode ( 4 )\\n\\troot . left = newNode ( 2 )\\n\\troot . right = newNode ( 7 )\\n\\troot . left . left = newNode ( 1 )\\n\\troot . left . right = newNode ( 3 )\\n\\troot . right . left = newNode ( 6 )\\n\\troot . right . right = newNode ( 10 )\\n\\tprint ( \\\" Finding ▁ K - th ▁ largest ▁ Node ▁ in ▁ BST ▁ : ▁ \\\" , KthLargestUsingMorrisTraversal ( root , 2 ) . data )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Maximum height of triangular arrangement of array values | PHP program to find the maximum height of Pyramidal Arrangement of array values ; Just checking whether ith level is possible or not if possible then we must have atleast ( i * ( i + 1 ) ) \\/ 2 elements in the array ; updating the result value each time ; otherwise we have exceeded n value ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function MaximumHeight ( $ a , $ n ) { $ result = 1 ; for ( $ i = 1 ; $ i <= $ n ; ++ $ i ) { $ y = ( $ i * ( $ i + 1 ) ) \\/ 2 ; if ( $ y < $ n ) $ result = $ i ; else break ; } return $ result ; } $ arr = array ( 40 , 100 , 20 , 30 ) ; $ n = count ( $ arr ) ; echo MaximumHeight ( $ arr , $ n ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Maximum subarray sum in an array created after repeated concatenation | Set | Function to find contiguous subarray with maximum sum if array is repeated K times ; Store the sum of the array arr [ ] ; Traverse the array and find sum ; Store the answer ; If K = 1 ; Apply Kadane algorithm to find sum ; Return the answer ; Stores the twice repeated array ; Traverse the range [ 0 , 2 * N ] ; Stores the maximum suffix sum ; Stores the maximum prefix sum ; Apply Kadane algorithm for 2 repetition of the array ; If the sum of the array is greater than 0 ; Return the answer ; Driver Code ; Given Input ; Function Call\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def maxSubArraySumRepeated ( arr , N , K ) :\\n\\tsum = 0\\n\\tfor i in range ( N ) :\\n\\t\\tsum += arr [ i ]\\n\\tcurr = arr [ 0 ]\\n\\tans = arr [ 0 ]\\n\\tif ( K == 1 ) :\\n\\t\\tfor i in range ( 1 , N , 1 ) :\\n\\t\\t\\tcurr = max ( arr [ i ] , curr + arr [ i ] )\\n\\t\\t\\tans = max ( ans , curr )\\n\\t\\treturn ans\\n\\tV = [ ]\\n\\tfor i in range ( 2 * N ) :\\n\\t\\tV . append ( arr [ i % N ] )\\n\\tmaxSuf = V [ 0 ]\\n\\tmaxPref = V [ 2 * N - 1 ]\\n\\tcurr = V [ 0 ]\\n\\tfor i in range ( 1 , 2 * N , 1 ) :\\n\\t\\tcurr += V [ i ]\\n\\t\\tmaxPref = max ( maxPref , curr )\\n\\tcurr = V [ 2 * N - 1 ]\\n\\ti = 2 * N - 2\\n\\twhile ( i >= 0 ) :\\n\\t\\tcurr += V [ i ]\\n\\t\\tmaxSuf = max ( maxSuf , curr )\\n\\t\\ti -= 1\\n\\tcurr = V [ 0 ]\\n\\tfor i in range ( 1 , 2 * N , 1 ) :\\n\\t\\tcurr = max ( V [ i ] , curr + V [ i ] )\\n\\t\\tans = max ( ans , curr )\\n\\tif ( sum > 0 ) :\\n\\t\\ttemp = sum * ( K - 2 )\\n\\t\\tans = max ( ans , max ( temp + maxPref , temp + maxSuf ) )\\n\\treturn ans\\nif __name__ == ' _ _ main _ _ ' :\\n\\tarr = [ 10 , 20 , - 30 , - 1 , 40 ]\\n\\tN = len ( arr )\\n\\tK = 10\\n\\tprint ( maxSubArraySumRepeated ( arr , N , K ) )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Minimize the difference between the maximum and minimum values of the modified array | Function to return required minimum difference ; finding minimum and maximum values ; returning minimum possible difference ; Driver program ; function to return the answer\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function minDiff ( $ n , $ x , $ A ) { $ mn = $ A [ 0 ] ; $ mx = $ A [ 0 ] ; for ( $ i = 0 ; $ i < $ n ; ++ $ i ) { $ mn = min ( $ mn , $ A [ $ i ] ) ; $ mx = max ( $ mx , $ A [ $ i ] ) ; } return max ( 0 , $ mx - $ mn - 2 * $ x ) ; } $ n = 3 ; $ x = 3 ; $ A = array ( 1 , 3 , 6 ) ; echo minDiff ( $ n , $ x , $ A ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Minimize steps to reach K from 0 by adding 1 or doubling at each step | C ++ program to implement the above approach ; Function to find minimum operations ; vector dp is initialised to store the steps ; For all even numbers ; Driver Code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int minOperation ( int k ) { vector < int > dp ( k + 1 , 0 ) ; for ( int i = 1 ; i <= k ; i ++ ) { dp [ i ] = dp [ i - 1 ] + 1 ; if ( i % 2 == 0 ) { dp [ i ] = min ( dp [ i ] , dp [ i \\/ 2 ] + 1 ) ; } } return dp [ k ] ; } int main ( ) { int K = 12 ; cout << minOperation ( k ) ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Construct a graph using N vertices whose shortest distance between K pair of vertices is 2 | C program to implement the above approach ; Function to construct the simple and connected graph such that the distance between exactly K pairs of vertices is 2 ; Stores maximum possible count of edges in a graph ; Base Case ; Stores count of edges in a graph ; Connect all vertices of pairs ( i , j ) ; Update ; Driver Code\\\"\\nSolution in C:\",\"targets\":\"#include \\nvoid constGraphWithCon ( int N , int K ) { int Max = ( ( N - 1 ) * ( N - 2 ) ) \\/ 2 ; if ( K > Max ) { printf ( \\\" - 1\\\" ) ; return ; } int count = 0 ; for ( int i = 1 ; i < N ; i ++ ) { for ( int j = i + 1 ; j <= N ; j ++ ) { printf ( \\\" % d ▁ % d \\n \\\" , i , j ) ; count ++ ; if ( count == N * ( N - 1 ) \\/ 2 - K ) break ; } if ( count == N * ( N - 1 ) \\/ 2 - K ) break ; } } int main ( ) { int N = 5 , K = 3 ; constGraphWithCon ( N , K ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Sum of Fibonacci Numbers with alternate negatives | C # Program to find alternate sum of Fibonacci numbers ; Computes value of first fibonacci numbers and stores their alternate sum ; Initialize result ; Add remaining terms ; For even terms ; For odd terms ; Return the alternating sum ; Driver code ; Get n ; Find the alternating sum\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static double calculateAlternateSum ( int n ) { if ( n <= 0 ) return 0 ; int [ ] fibo = new int [ n + 1 ] ; fibo [ 0 ] = 0 ; fibo [ 1 ] = 1 ; double sum = Math . Pow ( fibo [ 0 ] , 2 ) + Math . Pow ( fibo [ 1 ] , 2 ) ; for ( int i = 2 ; i <= n ; i ++ ) { fibo [ i ] = fibo [ i - 1 ] + fibo [ i - 2 ] ; if ( i % 2 == 0 ) sum -= fibo [ i ] ; else sum += fibo [ i ] ; } return sum ; } public static void Main ( ) { int n = 8 ; Console . WriteLine ( \\\" Alternating ▁ Fibonacci ▁ Sum ▁ upto ▁ \\\" + n + \\\" ▁ terms : ▁ \\\" + calculateAlternateSum ( n ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Rare Numbers | C ++ implementation to check if N is a Rare number ; Iterative function to reverse digits of num ; Function to check if N is perfect square ; Find floating point value of square root of x . ; If square root is an integer ; Function to check if N is an Rare number ; Find reverse of N ; Number should be non - palindromic ; Driver Code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int reversDigits ( int num ) { int rev_num = 0 ; while ( num > 0 ) { rev_num = rev_num * 10 + num % 10 ; num = num \\/ 10 ; } return rev_num ; } bool isPerfectSquare ( long double x ) { long double sr = sqrt ( x ) ; return ( ( sr - floor ( sr ) ) == 0 ) ; } bool isRare ( int N ) { int reverseN = reversDigits ( N ) ; if ( reverseN == N ) return false ; return isPerfectSquare ( N + reverseN ) && isPerfectSquare ( N - reverseN ) ; } int main ( ) { int n = 65 ; if ( isRare ( n ) ) cout << \\\" Yes \\\" ; else cout << \\\" No \\\" ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Count numbers from a given range that are not divisible by any of the array elements | Function to find the non - multiples till k ; Stores all unique multiples ; Iterate the array ; For finding duplicates only once ; Inserting all multiples into the set ; Returning only the count of numbers that are not divisible by any of the array elements ; Function to count the total values in the range [ L , R ] ; Count all values in the range using exclusion principle ; Driver Code ; Function Call\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function findNonMultiples ( arr , n , k ) { let multiples = new Set ( ) ; for ( let i = 0 ; i < n ; ++ i ) { if ( ! multiples . has ( arr [ i ] ) ) { for ( let j = 1 ; j <= k \\/ arr [ i ] ; j ++ ) { multiples . add ( arr [ i ] * j ) ; } } } return k - multiples . size ; } function countValues ( arr , N , L , R ) { return findNonMultiples ( arr , N , R ) - findNonMultiples ( arr , N , L - 1 ) ; } let arr = [ 2 , 3 , 4 , 5 , 6 ] ; let N = arr . length ; let L = 1 , R = 20 ; document . write ( countValues ( arr , N , L , R ) ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Check if any anagram of a string is palindrome or not | ; function to check whether characters of a string can form a palindrome ; Create a count array and initialize all values as 0 ; For each character in input strings , increment count in the corresponding count array ; Count odd occurring characters ; Return true if odd count is 0 or 1 , ; Driver program to test to print printDups\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; #define NO_OF_CHARS 256\\nbool canFormPalindrome ( string str ) { int count [ NO_OF_CHARS ] = { 0 } ; for ( int i = 0 ; str [ i ] ; i ++ ) count [ str [ i ] ] ++ ; int odd = 0 ; for ( int i = 0 ; i < NO_OF_CHARS ; i ++ ) { if ( count [ i ] & 1 ) odd ++ ; if ( odd > 1 ) return false ; } return true ; } int main ( ) { canFormPalindrome ( \\\" geeksforgeeks \\\" ) ? cout << \\\" Yes \\n \\\" : cout << \\\" No \\n \\\" ; canFormPalindrome ( \\\" geeksogeeks \\\" ) ? cout << \\\" Yes \\n \\\" : cout << \\\" No \\n \\\" ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Count ways to reach the nth stair using step 1 , 2 or 3 | A recursive function used by countWays ; Declaring three variables and holding the ways for first three stairs ; Fourth variable ; Starting from 4 as already counted for 3 stairs ; Driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function countWays ( n ) { var a = 1 , b = 2 , c = 4 ; var d = 0 ; if ( n == 0 n == 1 n == 2 ) return n ; if ( n == 3 ) return c ; for ( var i = 4 ; i <= n ; i ++ ) { d = c + b + a ; a = b ; b = c ; c = d ; } return d ; } var n = 4 ; document . write ( countWays ( n ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Print characters having prime frequencies in order of occurrence | Python 3 implementation of the approach ; Function to create Sieve to check primes ; false here indicates that it is not prime ; If prime [ p ] is not changed , then it is a prime ; Update all multiples of p , set them to non - prime ; Function to print the prime frequency characters in the order of their occurrence ; Function to create Sieve to check primes ; To store the frequency of each of the character of the string ; Update the frequency of each character ; Traverse str character by character ; If frequency of current character is prime ; Driver code\\\"\\nSolution in Python:\",\"targets\":\"SIZE = 26\\nfrom math import sqrt\\ndef SieveOfEratosthenes ( prime , p_size ) :\\n\\tprime [ 0 ] = False\\n\\tprime [ 1 ] = False\\n\\tfor p in range ( 2 , int ( sqrt ( p_size ) ) , 1 ) :\\n\\t\\tif ( prime [ p ] ) :\\n\\t\\t\\tfor i in range ( p * 2 , p_size , p ) :\\n\\t\\t\\t\\tprime [ i ] = False\\ndef printChar ( str , n ) :\\n\\tprime = [ True for i in range ( n + 1 ) ]\\n\\tSieveOfEratosthenes ( prime , len ( str ) + 1 )\\n\\tfreq = [ 0 for i in range ( SIZE ) ]\\n\\tfor i in range ( n ) :\\n\\t\\tfreq [ ord ( str [ i ] ) - ord ( ' a ' ) ] += 1\\n\\tfor i in range ( n ) :\\n\\t\\tif ( prime [ freq [ ord ( str [ i ] ) - ord ( ' a ' ) ] ] ) :\\n\\t\\t\\tprint ( str [ i ] , end = \\\" \\\" )\\nif __name__ == ' _ _ main _ _ ' :\\n\\tstr = \\\" geeksforgeeks \\\"\\n\\tn = len ( str )\\n\\tprintChar ( str , n )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Count pairs of non | Java implementation of the approach ; Pre - processing function ; Get the size of the string ; Initially mark every position as false ; For the length ; Iterate for every index with length j ; If the length is less than 2 ; If characters are equal ; Check for equal ; Function to return the number of pairs ; Create the dp table initially ; Declare the left array ; Declare the right array ; Initially left [ 0 ] is 1 ; Count the number of palindrome pairs to the left ; Initially right most as 1 ; Count the number of palindrome pairs to the right ; Count the number of pairs ; Driver code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"class GFG { static int N = 100 ; static void pre_process ( boolean dp [ ] [ ] , char [ ] s ) { int n = s . length ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { dp [ i ] [ j ] = false ; } } for ( int j = 1 ; j <= n ; j ++ ) { for ( int i = 0 ; i <= n - j ; i ++ ) { if ( j <= 2 ) { if ( s [ i ] == s [ i + j - 1 ] ) { dp [ i ] [ i + j - 1 ] = true ; } } else if ( s [ i ] == s [ i + j - 1 ] ) { dp [ i ] [ i + j - 1 ] = dp [ i + 1 ] [ i + j - 2 ] ; } } } } static int countPairs ( String s ) { boolean dp [ ] [ ] = new boolean [ N ] [ N ] ; pre_process ( dp , s . toCharArray ( ) ) ; int n = s . length ( ) ; int left [ ] = new int [ n ] ; int right [ ] = new int [ n ] ; left [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { for ( int j = 0 ; j <= i ; j ++ ) { if ( dp [ j ] [ i ] == true ) { left [ i ] ++ ; } } } right [ n - 1 ] = 1 ; for ( int i = n - 2 ; i >= 0 ; i -- ) { right [ i ] = right [ i + 1 ] ; for ( int j = n - 1 ; j >= i ; j -- ) { if ( dp [ i ] [ j ] == true ) { right [ i ] ++ ; } } } int ans = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { ans += left [ i ] * right [ i + 1 ] ; } return ans ; } public static void main ( String [ ] args ) { String s = \\\" abacaba \\\" ; System . out . println ( countPairs ( s ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Number of ways to arrange a word such that all vowels occur together | C ++ program to calculate the no . of ways to arrange the word having vowels together ; Factorial of a number ; calculating ways for arranging consonants ; Ignore vowels ; calculating ways for arranging vowels ; Function to count total no . of ways ; Count vowels and consonant ; total no . of ways ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\n#define ll long long int\\nusing namespace std ; ll fact ( int n ) { ll f = 1 ; for ( int i = 2 ; i <= n ; i ++ ) f = f * i ; return f ; } ll waysOfConsonants ( int size1 , int freq [ ] ) { ll ans = fact ( size1 ) ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( i == 0 i == 4 i == 8 i == 14 i == 20 ) continue ; else ans = ans \\/ fact ( freq [ i ] ) ; } return ans ; } ll waysOfVowels ( int size2 , int freq [ ] ) { return fact ( size2 ) \\/ ( fact ( freq [ 0 ] ) * fact ( freq [ 4 ] ) * fact ( freq [ 8 ] ) * fact ( freq [ 14 ] ) * fact ( freq [ 20 ] ) ) ; } ll countWays ( string str ) { int freq [ 26 ] = { 0 } ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) freq [ str [ i ] - ' a ' ] ++ ; int vowel = 0 , consonant = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str [ i ] != ' a ' && str [ i ] != ' e ' && str [ i ] != ' i ' && str [ i ] != ' o ' && str [ i ] != ' u ' ) consonant ++ ; else vowel ++ ; } return waysOfConsonants ( consonant + 1 , freq ) * waysOfVowels ( vowel , freq ) ; } int main ( ) { string str = \\\" geeksforgeeks \\\" ; cout << countWays ( str ) << endl ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Probability that a random pair chosen from an array ( a [ i ] , a [ j ] ) has the maximum sum | C ++ implementation of the approach ; Function to return the probability of getting the maximum pair sum when a random pair is chosen from the given array ; Initialize the maximum sum , its count and the count of total pairs ; For every single pair ; Get the sum of the current pair ; If the sum is equal to the current maximum sum so far ; Increment its count ; If the sum is greater than the current maximum ; Update the current maximum and re - initialize the count to 1 ; Find the required probability ; Driver code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; float findProb ( int arr [ ] , int n ) { long maxSum = INT_MIN , maxCount = 0 , totalPairs = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { int sum = arr [ i ] + arr [ j ] ; if ( sum == maxSum ) { maxCount ++ ; } else if ( sum > maxSum ) { maxSum = sum ; maxCount = 1 ; } totalPairs ++ ; } } float prob = ( float ) maxCount \\/ ( float ) totalPairs ; return prob ; } int main ( ) { int arr [ ] = { 1 , 1 , 1 , 2 , 2 , 2 } ; int n = sizeof ( arr ) \\/ sizeof ( int ) ; cout << findProb ( arr , n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Count valid pairs in the array satisfying given conditions | Function to return total valid pairs ; Initialize count of all the elements ; frequency count of all the elements ; Add total valid pairs ; Exclude pairs made with a single element i . e . ( x , x ) ; Driver Code ; Function call to print required answer\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function ValidPairs ( $ arr , $ n ) { $ count = array_fill ( 0 , 121 , 0 ) ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) $ count [ $ arr [ $ i ] ] += 1 ; $ ans = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) for ( $ j = 0 ; $ j < $ n ; $ j ++ ) { if ( $ arr [ $ i ] < $ arr [ $ j ] ) continue ; if ( abs ( $ arr [ $ i ] - $ arr [ $ j ] ) % 2 == 1 ) continue ; $ ans += $ count [ $ arr [ $ i ] ] * $ count [ $ arr [ $ j ] ] ; if ( $ arr [ $ i ] == $ arr [ $ j ] ) $ ans -= $ count [ $ arr [ $ i ] ] ; } return $ ans ; } $ arr = array ( 16 , 17 , 18 ) ; $ n = count ( $ arr ) ; echo ( ValidPairs ( $ arr , $ n ) ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Minimum letters to be removed to make all occurrences of a given letter continuous | Function to find the minimum number of deletions required to make the occurrences of the given character K continuous ; Find the first occurrence of the given letter ; Iterate from the first occurrence till the end of the sequence ; Find the index from where the occurrence of the character is not continuous ; Update the answer with the number of elements between non - consecutive occurrences of the given letter ; Update the count for all letters which are not equal to the given letter ; Return the count ; Driver code ; Calling the function ; Calling the function\\\"\\nSolution in Python:\",\"targets\":\"def noOfDeletions ( string , k ) :\\n\\tans = 0 ; cnt = 0 ; pos = 0 ;\\n\\twhile ( pos < len ( string ) and string [ pos ] != k ) :\\n\\t\\tpos += 1 ;\\n\\ti = pos ;\\n\\twhile ( i < len ( string ) ) :\\n\\t\\twhile ( i < len ( string ) and string [ i ] == k ) :\\n\\t\\t\\ti = i + 1 ;\\n\\t\\tans = ans + cnt ;\\n\\t\\tcnt = 0 ;\\n\\t\\twhile ( i < len ( string ) and string [ i ] != k ) :\\n\\t\\t\\ti = i + 1 ;\\n\\t\\t\\tcnt = cnt + 1 ;\\n\\treturn ans ;\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tstr1 = \\\" ababababa \\\" ;\\n\\tk1 = ' a ' ;\\n\\tprint ( noOfDeletions ( str1 , k1 ) ) ;\\n\\tstr2 = \\\" kprkkoinkopt \\\" ;\\n\\tk2 = ' k ' ;\\n\\tprint ( noOfDeletions ( str2 , k2 ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Number of NGEs to the right | ; array to store the next greater element index ; use of stl stack in c ++ ; push the 0 th index to the stack ; traverse in the loop from 1 - nth index ; iterate till loop is empty ; get the topmost index in the stack ; if the current element is greater then the top index - th element , then this will be the next greatest index of the top index - th element ; initialize the cur index position 's next greatest as index ; pop the cur index as its greater element has been found ; if not greater then break ; push the i index so that its next greatest can be found ; iterate for all other index left inside stack ; mark it as - 1 as no element in greater then it in right ; Function to count the number of next greater numbers to the right ; initializes the next array as 0 ; calls the function to pre - calculate the next greatest element indexes ; if the i - th element has no next greater element to right ; Count of next greater numbers to right . ; answers all queries in O ( 1 ) ; returns the number of next greater elements to the right . ; driver program to test the above function ; calls the function to count the number of greater elements to the right for every element . ; query 1 answered ; query 2 answered ; query 3 answered\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; void fillNext ( int next [ ] , int a [ ] , int n ) { stack < int > s ; s . push ( 0 ) ; for ( int i = 1 ; i < n ; i ++ ) { while ( ! s . empty ( ) ) { int cur = s . top ( ) ; if ( a [ cur ] < a [ i ] ) { next [ cur ] = i ; s . pop ( ) ; } else break ; } s . push ( i ) ; } while ( ! s . empty ( ) ) { int cur = s . top ( ) ; next [ cur ] = -1 ; s . pop ( ) ; } } void count ( int a [ ] , int dp [ ] , int n ) { int next [ n ] ; memset ( next , 0 , sizeof ( next ) ) ; fillNext ( next , a , n ) ; for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( next [ i ] == -1 ) dp [ i ] = 0 ; else dp [ i ] = 1 + dp [ next [ i ] ] ; } } int answerQuery ( int dp [ ] , int index ) { return dp [ index ] ; } int main ( ) { int a [ ] = { 3 , 4 , 2 , 7 , 5 , 8 , 10 , 6 } ; int n = sizeof ( a ) \\/ sizeof ( a [ 0 ] ) ; int dp [ n ] ; count ( a , dp , n ) ; cout << answerQuery ( dp , 3 ) << endl ; cout << answerQuery ( dp , 6 ) << endl ; cout << answerQuery ( dp , 1 ) << endl ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Length of the chord of the circle whose radius and the angle subtended at the center by the chord is given | C # program to find the length chord of the circle whose radius and the angle subtended at the centre is also given ; Function to find the length of the chord ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static void length_of_chord ( double r , double x ) { Console . WriteLine ( \\\" The ▁ length ▁ of ▁ the ▁ chord \\\" + \\\" ▁ of ▁ the ▁ circle ▁ is ▁ \\\" + 2 * r * Math . Sin ( x * ( 3.14 \\/ 180 ) ) ) ; } public static void Main ( String [ ] args ) { double r = 4 , x = 63 ; length_of_chord ( r , x ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Maximum element between two nodes of BST | JavaScript program to find maximum element in the path between two Nodes of Binary Search Tree . ; Create and return a pointer of new Node . ; Insert a new Node in Binary Search Tree . ; Return the maximum element between a Node and its given ancestor . ; Traversing the path between ansector and Node and finding maximum element . ; Return maximum element in the path between two given Node of BST . ; Finding the LCA of Node x and Node y ; Checking if both the Node lie on the left side of the parent p . ; Checking if both the Node lie on the right side of the parent p . ; Return the maximum of maximum elements occur in path from ancestor to both Node . ; Driver Code ; Creating the root of Binary Search Tree ; Inserting Nodes in Binary Search Tree\\\"\\nSolution in Javascript:\",\"targets\":\"class Node { constructor ( val ) { this . data = val ; this . left = null ; this . right = null ; } } function createNode ( x ) { var p = new Node ( ) ; p . data = x ; p . left = p . right = null ; return p ; } function insertNode ( root , x ) { var p = root , q = null ; while ( p != null ) { q = p ; if ( p . data < x ) p = p . right ; else p = p . left ; } if ( q == null ) p = createNode ( x ) ; else { if ( q . data < x ) q . right = createNode ( x ) ; else q . left = createNode ( x ) ; } } function maxelpath ( q , x ) { var p = q ; var mx = - 1 ; while ( p . data != x ) { if ( p . data > x ) { mx = Math . max ( mx , p . data ) ; p = p . left ; } else { mx = Math . max ( mx , p . data ) ; p = p . right ; } } return Math . max ( mx , x ) ; } function maximumElement ( root , x , y ) { var p = root ; while ( ( x < p . data && y < p . data ) || ( x > p . data && y > p . data ) ) { if ( x < p . data && y < p . data ) p = p . left ; else if ( x > p . data && y > p . data ) p = p . right ; } return Math . max ( maxelpath ( p , x ) , maxelpath ( p , y ) ) ; } var arr = [ 18 , 36 , 9 , 6 , 12 , 10 , 1 , 8 ] ; var a = 1 , b = 10 ; var n = arr . length ; var root = createNode ( arr [ 0 ] ) ; for ( i = 1 ; i < n ; i ++ ) insertNode ( root , arr [ i ] ) ; document . write ( maximumElement ( root , a , b ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Calculate score of a string consisting of balanced parentheses | C ++ program to implement the above approach ; Function to calculate score of parentheses ; Stores index of character of string ; Stores total scores obtained from the string ; Iterate over characters of the string ; If s [ i ] is ' ( ' ; If top element of stack is ' ( ' ; Stores score of inner parentheses ; Calculate score of inner parentheses ; Update count ; Pop from stack ; Insert score of inner parentheses ; Update i ; Calculate score of the string ; Update ans ; Driver Code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\n#include \\nusing namespace std ; long long scoreOfParentheses ( string S ) { stack < string > s ; int i = 0 ; long long ans = 0 ; while ( i < S . length ( ) ) { if ( S [ i ] == ' ( ' ) s . push ( \\\" ( \\\" ) ; else { if ( s . top ( ) == \\\" ( \\\" ) { s . pop ( ) ; s . push ( \\\"1\\\" ) ; } else { long long count = 0 ; while ( s . top ( ) != \\\" ( \\\" ) { count += stoi ( s . top ( ) ) ; s . pop ( ) ; } s . pop ( ) ; s . push ( to_string ( 2 * count ) ) ; } } i ++ ; } while ( ! s . empty ( ) ) { ans += stoi ( s . top ( ) ) ; s . pop ( ) ; } return ans ; } int main ( ) { string S1 = \\\" ( ( ) ( ( ) ) ) \\\" ; cout << scoreOfParentheses ( S1 ) << endl ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Check if an array is Wave Array | Function to check if array is wave array arr : input array n : size of array ; Check the wave form * If arr [ 1 ] is greater than left and right * Same pattern will be followed by whole * elements , else reverse pattern * will be followed by array elements ; Check for last element ; Check for last element ; Array\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function isWaveArray ( $ arr , $ n ) { $ result = true ; if ( $ arr [ 1 ] > $ arr [ 0 ] && $ arr [ 1 ] > $ arr [ 2 ] ) { for ( $ i = 1 ; $ i < ( $ n - 1 ) ; $ i += 2 ) { if ( $ arr [ $ i ] > $ arr [ $ i - 1 ] && $ arr [ $ i ] > $ arr [ $ i + 1 ] ) { $ result = true ; } else { $ result = false ; break ; } } if ( $ result == true && $ n % 2 == 0 ) { if ( $ arr [ $ n - 1 ] <= $ arr [ $ n - 2 ] ) { $ result = false ; } } } else if ( $ arr [ 1 ] < $ arr [ 0 ] && $ arr [ 1 ] < $ arr [ 2 ] ) { for ( $ i = 1 ; $ i < $ n - 1 ; $ i += 2 ) { if ( $ arr [ $ i ] < $ arr [ $ i - 1 ] && $ arr [ $ i ] < $ arr [ $ i + 1 ] ) { $ result = true ; } else { $ result = false ; break ; } } if ( $ result == true && $ n % 2 == 0 ) { if ( $ arr [ $ n - 1 ] >= $ arr [ $ n - 2 ] ) { $ result = false ; } } } return $ result ; } $ arr = array ( 1 , 3 , 2 , 4 ) ; $ n = sizeof ( $ arr ) ; if ( isWaveArray ( $ arr , $ n ) ) { echo \\\" YES \\\" ; } else { echo \\\" NO \\\" ; } ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Check if the first and last digit of the smallest number forms a prime | function to check prime ; Function to generate smallest possible number with given digits ; Declare a hash array of size 10 and initialize all the elements to zero ; store the number of occurrences of the digits in the given array into the hash table ; Traverse the hash in ascending order to print the required number ; Print the number of times a digits occurs ; extracting the first digit ; extracting the last digit ; printing the prime combinations ; Driver code\\\"\\nSolution in Javascript:\",\"targets\":\"function isPrime ( n ) { var i , c = 0 ; for ( i = 1 ; i < n \\/ 2 ; i ++ ) { if ( n % i == 0 ) c ++ ; } if ( c == 1 ) return 1 ; else return 0 ; } function findMinNum ( arr , n ) { var first = 0 , last = 0 , num , rev , i ; var hash = new Array ( 10 ) . fill ( 0 ) ; for ( var i = 0 ; i < n ; i ++ ) { hash [ arr [ i ] ] ++ ; } document . write ( \\\" \\\" ) ; for ( var i = 0 ; i <= 9 ; i ++ ) { for ( var j = 0 ; j < hash [ i ] ; j ++ ) document . write ( i ) ; } document . write ( \\\" \\\" ) ; for ( i = 0 ; i <= 9 ; i ++ ) { if ( hash [ i ] != 0 ) { first = i ; break ; } } for ( i = 9 ; i >= 0 ; i -- ) { if ( hash [ i ] != 0 ) { last = i ; break ; } } num = first * 10 + last ; rev = last * 10 + first ; document . write ( \\\" \\\" ) ; if ( isPrime ( num ) && isPrime ( rev ) ) document . write ( num + \\\" \\\" + rev ) ; else if ( isPrime ( num ) ) document . write ( num ) ; else if ( isPrime ( rev ) ) document . write ( rev ) ; else document . write ( \\\" \\\" ) ; } var arr = [ 1 , 2 , 4 , 7 , 8 ] ; findMinNum ( arr , 5 ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Given an array arr [ ] , find the maximum j | For a given array arr , calculates the maximum j a i such that arr [ j ] > arr [ i ] ; Create an array maxfromEnd ; We store this as current answer and look for further larger number to the right side ; Keeping a track of the maximum difference in indices\\\"\\nHow can the above be solved in Python?\",\"targets\":\"if __name__ == ' _ _ main _ _ ' :\\n\\tv = [ 34 , 8 , 10 , 3 , 2 , 80 , 30 , 33 , 1 ] ;\\n\\tn = len ( v ) ;\\n\\tmaxFromEnd = [ - 38749432 ] * ( n + 1 ) ;\\n\\tfor i in range ( n - 1 , 0 , - 1 ) :\\n\\t\\tmaxFromEnd [ i ] = max ( maxFromEnd [ i + 1 ] , v [ i ] ) ;\\n\\tresult = 0 ;\\n\\tfor i in range ( 0 , n ) :\\n\\t\\tlow = i + 1 ; high = n - 1 ; ans = i ;\\n\\t\\twhile ( low <= high ) :\\n\\t\\t\\tmid = int ( ( low + high ) \\/ 2 ) ;\\n\\t\\t\\tif ( v [ i ] <= maxFromEnd [ mid ] ) :\\n\\t\\t\\t\\tans = max ( ans , mid ) ;\\n\\t\\t\\t\\tlow = mid + 1 ;\\n\\t\\t\\telse :\\n\\t\\t\\t\\thigh = mid - 1 ;\\n\\t\\tresult = max ( result , ans - i ) ;\\n\\tprint ( result , end = \\\" \\\" ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Count of cyclic permutations having XOR with other binary string as 0 | Implementation of Z - algorithm for linear time pattern searching ; Function to get the count of the cyclic permutations of b that given 0 when XORed with a ; concatenate b with b ; new b now contains all the cyclic permutations of old b as it 's sub-strings ; concatenate pattern with text ; Fill z array used in Z algorithm ; pattern occurs at index i since z value of i equals pattern length ; Driver Code\\\"\\nSolution in Javascript:\",\"targets\":\"function compute_z ( s , z ) { var l = 0 , r = 0 ; var n = s . length ; for ( var i = 1 ; i <= n - 1 ; i ++ ) { if ( i > r ) { l = i ; r = i ; while ( r < n && s [ r - l ] === s [ r ] ) { r ++ ; } z [ i ] = r - l ; r -- ; } else { var k = i - l ; if ( z [ k ] < r - i + 1 ) { z [ i ] = z [ k ] ; } else { l = i ; while ( r < n && s [ r - l ] === s [ r ] ) { r ++ ; } z [ i ] = r - l ; r -- ; } } } } function countPermutation ( a , b ) { b = b + b ; b = b . substring ( 0 , b . length - 1 ) ; var ans = 0 ; var s = a + \\\" \\\" + b ; var n = s . length ; var z = new Array ( n ) . fill ( 0 ) ; compute_z ( s , z ) ; for ( var i = 1 ; i <= n - 1 ; i ++ ) { if ( z [ i ] === a . length ) { ans ++ ; } } return ans ; } var a = \\\" \\\" ; var b = \\\" \\\" ; document . write ( countPermutation ( a , b ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Coin Change | DP | Dynamic Programming C # implementation of Coin Change problem ; table [ i ] will be storing the number of solutions for value i . We need n + 1 rows as the table is constructed in bottom up manner using the base case ( n = 0 ) ; Base case ( If given value is 0 ) ; Pick all coins one by one and update the table [ ] values after the index greater than or equal to the value of the picked coin ; Driver Code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static int count ( int [ ] S , int m , int n ) { int [ ] table = new int [ n + 1 ] ; table [ 0 ] = 1 ; for ( int i = 0 ; i < m ; i ++ ) for ( int j = S [ i ] ; j <= n ; j ++ ) table [ j ] += table [ j - S [ i ] ] ; return table [ n ] ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 } ; int m = arr . Length ; int n = 4 ; Console . Write ( count ( arr , m , n ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Convert 0 to N by adding 1 or multiplying by 2 in minimum steps | C # program for above approach ; Function to count number of set bits in N ; Stores the count of set bits ; If N is odd , then it a set bit ; Return the result ; Driver Code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; public class GFG { static int minimumAdditionOperation ( int N ) { int count = 0 ; while ( N != 0 ) { if ( ( N & 1 ) == 1 ) { count ++ ; } N = N >> 1 ; } return count ; } static public void Main ( ) { int N = 6 ; Console . Write ( minimumAdditionOperation ( N ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Diameter of a Binary Tree | Recursive optimized C program to find the diameter of a Binary Tree ; A binary tree node has data , pointer to left child and a pointer to right child ; Helper function that allocates a new node with the given data and NULL left and right pointers . ; returns max of two integers ; The function Compute the \\\" height \\\" of a tree . Height is the number f nodes along the longest path from the root node down to the farthest leaf node . ; base case tree is empty ; If tree is not empty then height = 1 + max of left height and right heights ; Function to get diameter of a binary tree ; base case where tree is empty ; get the height of left and right sub - trees ; get the diameter of left and right sub - trees ; Return max of following three 1 ) Diameter of left subtree 2 ) Diameter of right subtree 3 ) Height of left subtree + height of right subtree + 1 ; Driver Code ; Constructed binary tree is 1 \\/ \\\\ 2 3 \\/ \\\\ 4 5 ; Function Call\\\"\\nSolution in C:\",\"targets\":\"#include \\n#include \\nstruct node { int data ; struct node * left , * right ; } ; struct node * newNode ( int data ) { struct node * node = ( struct node * ) malloc ( sizeof ( struct node ) ) ; node -> data = data ; node -> left = NULL ; node -> right = NULL ; return ( node ) ; } int max ( int a , int b ) { return ( a > b ) ? a : b ; } int height ( struct node * node ) { if ( node == NULL ) return 0 ; return 1 + max ( height ( node -> left ) , height ( node -> right ) ) ; } int diameter ( struct node * tree ) { if ( tree == NULL ) return 0 ; int lheight = height ( tree -> left ) ; int rheight = height ( tree -> right ) ; int ldiameter = diameter ( tree -> left ) ; int rdiameter = diameter ( tree -> right ) ; return max ( lheight + rheight + 1 , max ( ldiameter , rdiameter ) ) ; } int main ( ) { struct node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> left -> left = newNode ( 4 ) ; root -> left -> right = newNode ( 5 ) ; printf ( \\\" Diameter ▁ of ▁ the ▁ given ▁ binary ▁ tree ▁ is ▁ % d \\n \\\" , diameter ( root ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Find the smallest missing number | function that returns smallest elements missing in a sorted array . ; Left half has all elements from 0 to mid ; Driver Code\\\"\\nSolution in Javascript:\",\"targets\":\"function findFirstMissing ( array , start , end ) { if ( start > end ) return end + 1 ; if ( start != array [ start ] ) return start ; let mid = parseInt ( ( start + end ) \\/ 2 , 10 ) ; if ( array [ mid ] == mid ) return findFirstMissing ( array , mid + 1 , end ) ; return findFirstMissing ( array , start , mid ) ; } let arr = [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 10 ] ; let n = arr . length ; document . write ( \\\" \\\" + findFirstMissing ( arr , 0 , n - 1 ) ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Find extra element in the second array | Java implementation of the approach ; Function to return the extra element in B [ ] ; To store the result ; Find the XOR of all the element of array A [ ] and array B [ ] ; Driver code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"class GFG { static int extraElement ( int A [ ] , int B [ ] , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) ans ^= A [ i ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) ans ^= B [ i ] ; return ans ; } public static void main ( String [ ] args ) { int A [ ] = { 10 , 15 , 5 } ; int B [ ] = { 10 , 100 , 15 , 5 } ; int n = A . length ; System . out . println ( extraElement ( A , B , n ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Print indices of array elements whose removal makes the sum of odd and even | Function to find indices of array elements whose removal makes the sum of odd and even indexed array elements equal ; Stores size of array ; Store prefix sum of odd index array elements ; Store prefix sum of even index array elements ; Update even [ 0 ] ; Traverse the given array ; Update odd [ i ] ; Update even [ i ] ; If the current index is an even number ; Update even [ i ] ; If the current index is an odd number ; Update odd [ i ] ; Check if at least one index found or not that satisfies the condition ; Store odd indices sum by removing 0 - th index ; Store even indices sum by removing 0 - th index ; If p and q are equal ; Traverse the array arr ; If i is an even number ; Update p by removing the i - th element ; Update q by removing the i - th element ; Update q by removing the i - th element ; Update p by removing the i - th element ; If odd index values sum is equal to even index values sum ; Set the find variable ; Print the current index ; If no index found ; Print not possible ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def removeIndicesToMakeSumEqual ( arr ) :\\n\\tN = len ( arr ) ;\\n\\todd = [ 0 ] * N ;\\n\\teven = [ 0 ] * N ;\\n\\teven [ 0 ] = arr [ 0 ] ;\\n\\tfor i in range ( 1 , N ) :\\n\\t\\todd [ i ] = odd [ i - 1 ] ;\\n\\t\\teven [ i ] = even [ i - 1 ] ;\\n\\t\\tif ( i % 2 == 0 ) :\\n\\t\\t\\teven [ i ] += arr [ i ] ;\\n\\t\\telse :\\n\\t\\t\\todd [ i ] += arr [ i ] ;\\n\\tfind = False ;\\n\\tp = odd [ N - 1 ] ;\\n\\tq = even [ N - 1 ] - arr [ 0 ] ;\\n\\tif ( p == q ) :\\n\\t\\tprint ( \\\"0 ▁ \\\" ) ;\\n\\t\\tfind = True ;\\n\\tfor i in range ( 1 , N ) :\\n\\t\\tif ( i % 2 == 0 ) :\\n\\t\\t\\tp = even [ N - 1 ] - even [ i - 1 ] - arr [ i ] + odd [ i - 1 ] ;\\n\\t\\t\\tq = odd [ N - 1 ] - odd [ i - 1 ] + even [ i - 1 ] ;\\n\\t\\telse :\\n\\t\\t\\tq = odd [ N - 1 ] - odd [ i - 1 ] - arr [ i ] + even [ i - 1 ] ;\\n\\t\\t\\tp = even [ N - 1 ] - even [ i - 1 ] + odd [ i - 1 ] ;\\n\\t\\tif ( p == q ) :\\n\\t\\t\\tfind = True ;\\n\\t\\t\\tprint ( i , end = \\\" \\\" ) ;\\n\\tif ( find == False ) :\\n\\t\\tprint ( - 1 ) ;\\nif __name__ == ' _ _ main _ _ ' :\\n\\tarr = [ 4 , 1 , 6 , 2 ] ;\\n\\tremoveIndicesToMakeSumEqual ( arr ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Reverse actual bits of the given number | function to reverse bits of a number ; traversing bits of ' n ' from the right ; bitwise left shift ' rev ' by 1 ; if current bit is '1' ; bitwise right shift ' n ' by 1 ; required number ; Driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function reverseBits ( n ) { let rev = 0 ; while ( n > 0 ) { rev <<= 1 ; if ( ( n & 1 ) == 1 ) rev ^= 1 ; n >>= 1 ; } return rev ; } let n = 11 ; document . write ( reverseBits ( n ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Check a number is odd or even without modulus operator | Returns true if n is even , else odd ; Driver code\\\"\\nSolution in Javascript:\",\"targets\":\"function isEven ( n ) { let isEven = true ; for ( let i = 1 ; i <= n ; i ++ ) isEven = ! isEven ; return isEven ; } let n = 101 ; if ( isEven ( n ) ) document . write ( \\\" \\\" ) ; else document . write ( \\\" \\\" ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Count set bits in an integer | C program to count set bits by pre - storing count set bits in nibbles . ; Recursively get nibble of a given number and map them in the array ; Find last nibble ; Use pre - stored values to find count in last nibble plus recursively add remaining nibbles . ; Driver code\\\"\\nSolution in C:\",\"targets\":\"#include \\nint num_to_bits [ 16 ] = { 0 , 1 , 1 , 2 , 1 , 2 , 2 , 3 , 1 , 2 , 2 , 3 , 2 , 3 , 3 , 4 } ; unsigned int countSetBitsRec ( unsigned int num ) { int nibble = 0 ; if ( 0 == num ) return num_to_bits [ 0 ] ; nibble = num & 0xf ; return num_to_bits [ nibble ] + countSetBitsRec ( num >> 4 ) ; } int main ( ) { int num = 31 ; printf ( \\\" % d \\n \\\" , countSetBitsRec ( num ) ) ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Maximum equlibrium sum in an array | C # program to find maximum equilibrium sum . ; Function to find maximum equilibrium sum . ; Driver Code\\\"\\nSolution in C#:\",\"targets\":\"using System . Linq ; using System ; class GFG { static int Add ( int x , int y ) { return x + y ; } static int findMaxSum ( int [ ] arr , int n ) { int sum = arr . Aggregate ( func : Add ) ; int prefix_sum = 0 , res = int . MinValue ; for ( int i = 0 ; i < n ; i ++ ) { prefix_sum += arr [ i ] ; if ( prefix_sum == sum ) res = Math . Max ( res , prefix_sum ) ; sum -= arr [ i ] ; } return res ; } public static void Main ( ) { int [ ] arr = { - 2 , 5 , 3 , 1 , 2 , 6 , - 4 , 2 } ; int n = arr . Length ; Console . Write ( findMaxSum ( arr , n ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Largest palindromic number in an array | Function to check if n is palindrome ; Find the appropriate divisor to extract the leading digit ; If first and last digits are not same then return false ; Removing the leading and trailing digits from the number ; Reducing divisor by a factor of 2 as 2 digits are dropped ; Function to find the largest palindromic number ; Sort the array ; If number is palindrome ; If no palindromic number found ; Driver Code ; print required answer\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function isPalindrome ( $ n ) { $ divisor = 1 ; while ( ( int ) ( $ n \\/ $ divisor ) >= 10 ) $ divisor *= 10 ; while ( $ n != 0 ) { $ leading = ( int ) ( $ n \\/ $ divisor ) ; $ trailing = $ n % 10 ; if ( $ leading != $ trailing ) return false ; $ n = ( int ) ( ( $ n % $ divisor ) \\/ 10 ) ; $ divisor = ( int ) ( $ divisor \\/ 100 ) ; } return true ; } function largestPalindrome ( $ A , $ n ) { sort ( $ A ) ; for ( $ i = $ n - 1 ; $ i >= 0 ; -- $ i ) { if ( isPalindrome ( $ A [ $ i ] ) ) return $ A [ $ i ] ; } return -1 ; } $ A = array ( 1 , 232 , 54545 , 999991 ) ; $ n = sizeof ( $ A ) ; echo largestPalindrome ( $ A , $ n ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Minimum number of given moves required to reach ( 1 , 1 ) from ( X , Y ) | C # program for the above approach ; Function to count the number of steps required to convert ( x , y ) to ( 1 , 1 ) ; Store the required result ; Iterate while both x and y are not equal to 0 ; If x is greater than y ; Update count and value of x ; Otherwise ; Update count and value of y ; If both x and y > 1 ; Print the result ; Driver Code ; Given X and Y\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { public static void minimumSteps ( int x , int y ) { int cnt = 0 ; while ( x != 0 && y != 0 ) { if ( x > y ) { cnt += x \\/ y ; x %= y ; } else { cnt += y \\/ x ; y %= x ; } } cnt -- ; if ( x > 1 y > 1 ) cnt = - 1 ; Console . WriteLine ( cnt ) ; } public static void Main ( ) { int x = 3 , y = 1 ; minimumSteps ( x , y ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Represent N as sum of K even numbers | C ++ implementation to represent N as sum of K even numbers ; Function to print the representation ; N must be greater than equal to 2 * K and must be even ; Driver Code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; void sumEvenNumbers ( int N , int K ) { int check = N - 2 * ( K - 1 ) ; if ( check > 0 && check % 2 == 0 ) { for ( int i = 0 ; i < K - 1 ; i ++ ) { cout << \\\"2 ▁ \\\" ; } cout << check ; } else { cout << \\\" - 1\\\" ; } } int main ( ) { int N = 8 ; int K = 2 ; sumEvenNumbers ( N , K ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Maximum length of consecutive 1 s or 0 s after flipping at most K characters | Function to find the maximum length continuos segment of character c after flipping at most K characters ; Stores the maximum length ; Stores the count of char 'c ; Start of window ; Remove the extra ' c ' from left ; Increment the value of the left ; Update the resultant maximum length of character ch ; Function to find the maximum length of consecutive 0 s or 1 s by flipping at most K characters of the string ; Print the maximum of the maximum length of 0 s or 1 s ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"def maxLength ( str , n , c , k ) :\\n\\tans = - 1\\n'\\n\\tcnt = 0\\n\\tleft = 0\\n\\tfor right in range ( 0 , n ) :\\n\\t\\tif ( str [ right ] == c ) :\\n\\t\\t\\tcnt += 1\\n\\t\\twhile ( cnt > k ) :\\n\\t\\t\\tif ( str [ left ] == c ) :\\n\\t\\t\\t\\tcnt -= 1\\n\\t\\t\\tleft += 1\\n\\t\\tans = max ( ans , right - left + 1 )\\n\\treturn ans\\ndef maxConsecutiveSegment ( S , K ) :\\n\\tN = len ( S )\\n\\treturn max ( maxLength ( S , N , '0' , K ) , maxLength ( S , N , '1' , K ) )\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tS = \\\"1001\\\"\\n\\tK = 1\\n\\tprint ( maxConsecutiveSegment ( S , K ) )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Minimize steps required to make two values equal by repeated division by any of their prime factor which is less than M | C # program for the above approach ; Stores the prime factor of numbers ; Function to find GCD of a and b ; Base Case ; Otherwise , calculate GCD ; Function to precompute the prime numbers till 1000000 ; Initialize all the positions with their respective values ; Iterate over the range [ 2 , sqrt ( 10 ^ 6 ) ] ; If i is prime number ; Mark it as the factor ; Utility function to count the number of steps to make X and Y equal ; Initialise steps ; Iterate x is at most 1 ; Divide with the smallest prime factor ; If X and Y can 't be made equal ; Return steps ; Function to find the minimum number of steps required to make X and Y equal ; Generate all the prime factors ; Calculate GCD of x and y ; Divide the numbers by their gcd ; If not possible , then return - 1 ; ; Return the resultant number of steps ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int [ ] primes = new int [ 1000006 ] ; static int gcd ( int a , int b ) { if ( b == 0 ) return a ; else return gcd ( b , a % b ) ; } static void preprocess ( ) { for ( int i = 1 ; i <= 1000000 ; i ++ ) primes [ i ] = i ; for ( int i = 2 ; i * i <= 1000000 ; i ++ ) { if ( primes [ i ] == i ) { for ( int j = 2 * i ; j <= 1000000 ; j += i ) { if ( primes [ j ] == j ) primes [ j ] = i ; } } } } static int Steps ( int x , int m ) { int steps = 0 ; bool flag = false ; while ( x > 1 ) { if ( primes [ x ] > m ) { flag = true ; break ; } x \\/= primes [ x ] ; steps ++ ; } if ( flag ) return - 1 ; return steps ; } static int minimumSteps ( int x , int y , int m ) { preprocess ( ) ; int g = gcd ( x , y ) ; x = x \\/ g ; y = y \\/ g ; int x_steps = Steps ( x , m ) ; int y_steps = Steps ( y , m ) ; if ( x_steps == - 1 y_steps == - 1 ) return - 1 ; return x_steps + y_steps ; } static void Main ( ) { int X = 160 ; int Y = 180 ; int M = 10 ; Console . Write ( minimumSteps ( X , Y , M ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Program to check if an array is sorted or not ( Iterative and Recursive ) | C ++ program to check if an Array is sorted or not ; Function that returns true if array is sorted in non - decreasing order . ; Array has one or no element ; Unsorted pair found ; No unsorted pair found ; Driver code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; bool arraySortedOrNot ( int arr [ ] , int n ) { if ( n == 0 n == 1 ) return true ; for ( int i = 1 ; i < n ; i ++ ) if ( arr [ i - 1 ] > arr [ i ] ) return false ; return true ; } int main ( ) { int arr [ ] = { 20 , 23 , 23 , 45 , 78 , 88 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; if ( arraySortedOrNot ( arr , n ) ) cout << \\\" Yes \\n \\\" ; else cout << \\\" No \\n \\\" ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Program to print prime numbers from 1 to N . | Function to print first N prime numbers ; Declare the variables ; Print display message ; Traverse each number from 1 to N with the help of for loop ; Skip 0 and 1 as they are neither prime nor composite ; flag variable to tell if i is prime or not ; flag = 1 means i is prime and flag = 0 means i is not prime ; Driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function print_primes_till_N ( N ) { let i , j , flag ; document . write ( \\\" \\\" + N + \\\" \\\" ) ; for ( i = 1 ; i <= N ; i ++ ) { if ( i == 1 i == 0 ) continue ; flag = 1 ; for ( j = 2 ; j <= i \\/ 2 ; ++ j ) { if ( i % j == 0 ) { flag = 0 ; break ; } } if ( flag == 1 ) document . write ( i + \\\" \\\" ) ; } } let N = 100 ; print_primes_till_N ( N ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Babylonian method for square root | Returns the square root of n . Note that the function ; We are using n itself as initial approximation This can definitely be improved ; e decides the accuracy level ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function squareRoot ( $ n ) { $ x = $ n ; $ y = 1 ; $ e = 0.000001 ; while ( $ x - $ y > $ e ) { $ x = ( $ x + $ y ) \\/ 2 ; $ y = $ n \\/ $ x ; } return $ x ; } { $ n = 50 ; echo \\\" Square ▁ root ▁ of ▁ $ n ▁ is ▁ \\\" , squareRoot ( $ n ) ; } ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Maximum sum combination from two arrays | Java program to maximum sum combination from two arrays ; Function to maximum sum combination from two arrays ; To store dp value ; For loop to calculate the value of dp ; Return the required answer ; Driver code ; Function call\\\"\\nHow can the above be solved in Java?\",\"targets\":\"class GFG { static int Max_Sum ( int arr1 [ ] , int arr2 [ ] , int n ) { int [ ] [ ] dp = new int [ n ] [ 2 ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == 0 ) { dp [ i ] [ 0 ] = arr1 [ i ] ; dp [ i ] [ 1 ] = arr2 [ i ] ; continue ; } dp [ i ] [ 0 ] = Math . max ( dp [ i - 1 ] [ 0 ] , dp [ i - 1 ] [ 1 ] + arr1 [ i ] ) ; dp [ i ] [ 1 ] = Math . max ( dp [ i - 1 ] [ 1 ] , dp [ i - 1 ] [ 0 ] + arr2 [ i ] ) ; } return Math . max ( dp [ n - 1 ] [ 0 ] , dp [ n - 1 ] [ 1 ] ) ; } public static void main ( String [ ] args ) { int arr1 [ ] = { 9 , 3 , 5 , 7 , 3 } ; int arr2 [ ] = { 5 , 8 , 1 , 4 , 5 } ; int n = arr1 . length ; System . out . println ( Max_Sum ( arr1 , arr2 , n ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Coprime divisors of a number | Function which finds the required pair of divisors of N ; We iterate upto sqrt ( N ) as we can find all the divisors of N in this time ; If x is a divisor of N keep dividing as long as possible ; We have found a required pair ; No such pair of divisors of N was found , hence print - 1 ; Sample example 1 ; Sample example 2\\\"\\nSolution in Javascript:\",\"targets\":\"function findCoprimePair ( N ) { for ( let x = 2 ; x <= Math . sqrt ( N ) ; x ++ ) { if ( N % x == 0 ) { while ( N % x == 0 ) { N = Math . floor ( N \\/ x ) ; } if ( N > 1 ) { document . write ( x + \\\" \\\" + N + \\\" \\\" ) ; return ; } } } document . write ( - 1 + \\\" \\\" ) ; } let N = 45 ; findCoprimePair ( N ) ; N = 25 ; findCoprimePair ( N ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Find number of pairs in an array such that their XOR is 0 | Java program to find number of pairs in an array such that their XOR is 0 ; Function to calculate the count ; Sorting the list using built in function ; Traversing through the elements ; Counting frequency of each elements ; Adding the contribution of the frequency to the answer ; Driver Code ; Print the count\\\"\\nSolution in Java:\",\"targets\":\"import java . util . * ; class GFG { static int calculate ( int a [ ] , int n ) { Arrays . sort ( a ) ; int count = 1 ; int answer = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( a [ i ] == a [ i - 1 ] ) { count += 1 ; } else { answer = answer + ( count * ( count - 1 ) ) \\/ 2 ; count = 1 ; } } answer = answer + ( count * ( count - 1 ) ) \\/ 2 ; return answer ; } public static void main ( String [ ] args ) { int a [ ] = { 1 , 2 , 1 , 2 , 4 } ; int n = a . length ; System . out . println ( calculate ( a , n ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Find N distinct numbers whose Bitwise XOR is equal to K | Function to find N integers having Bitwise XOR equal to K ; Base Cases ; Assign values to P and Q ; Stores Bitwise XOR of the first ( N - 3 ) elements ; Print the first N - 3 elements ; Calculate Bitwise XOR of first ( N - 3 ) elements ; Driver Code ; Function Call\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def findArray ( N , K ) :\\n\\tif ( N == 1 ) :\\n\\t\\tprint ( K , end = \\\" ▁ \\\" )\\n\\t\\treturn\\n\\tif ( N == 2 ) :\\n\\t\\tprint ( \\\"0\\\" , end = \\\" ▁ \\\" )\\n\\t\\tprint ( K , end = \\\" ▁ \\\" )\\n\\t\\treturn\\n\\tP = N - 2\\n\\tQ = N - 1\\n\\tVAL = 0\\n\\tfor i in range ( 1 , N - 2 ) :\\n\\t\\tprint ( i , end = \\\" ▁ \\\" )\\n\\t\\tVAL ^= i\\n\\tif ( VAL == K ) :\\n\\t\\tprint ( P , end = \\\" ▁ \\\" )\\n\\t\\tprint ( Q , end = \\\" ▁ \\\" )\\n\\t\\tprint ( P ^ Q , end = \\\" ▁ \\\" )\\n\\telse :\\n\\t\\tprint ( \\\"0\\\" , end = \\\" ▁ \\\" )\\n\\t\\tprint ( P , end = \\\" ▁ \\\" )\\n\\t\\tprint ( P ^ K ^ VAL , end = \\\" ▁ \\\" )\\nN = 4\\nX = 6\\nfindArray ( N , X )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Partition problem | DP | A utility function that returns true if there is a subset of arr [ ] with sun equal to given sum ; Base Cases ; If last element is greater than sum , then ignore it ; else , check if sum can be obtained by any of the following ( a ) including the last element ( b ) excluding the last element ; Returns true if arr [ ] can be partitioned in two subsets of equal sum , otherwise false ; Calculate sum of the elements in array ; If sum is odd , there cannot be two subsets with equal sum ; Find if there is subset with sum equal to half of total sum ; Driver code ; Function call\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def isSubsetSum ( arr , n , sum ) :\\n\\tif sum == 0 :\\n\\t\\treturn True\\n\\tif n == 0 and sum != 0 :\\n\\t\\treturn False\\n\\tif arr [ n - 1 ] > sum :\\n\\t\\treturn isSubsetSum ( arr , n - 1 , sum )\\n\\treturn isSubsetSum ( arr , n - 1 , sum ) or isSubsetSum ( arr , n - 1 , sum - arr [ n - 1 ] )\\ndef findPartion ( arr , n ) :\\n\\tsum = 0\\n\\tfor i in range ( 0 , n ) :\\n\\t\\tsum += arr [ i ]\\n\\tif sum % 2 != 0 :\\n\\t\\treturn false\\n\\treturn isSubsetSum ( arr , n , sum \\/\\/ 2 )\\narr = [ 3 , 1 , 5 , 9 , 12 ]\\nn = len ( arr )\\nif findPartion ( arr , n ) == True :\\n\\tprint ( \\\" Can ▁ be ▁ divided ▁ into ▁ two ▁ subsets ▁ of ▁ equal ▁ sum \\\" )\\nelse :\\n\\tprint ( \\\" Can ▁ not ▁ be ▁ divided ▁ into ▁ two ▁ subsets ▁ of ▁ equal ▁ sum \\\" )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Minimum rotations required to get the same String | Set | C ++ implementation of the above approach ; Prints occurrences of txt [ ] in pat [ ] ; Create lps [ ] that will hold the longest prefix suffix values for pattern ; Preprocess the pattern ( calculate lps [ ] array ) ; Index for txt [ ] , index for pat [ ] ; Mismatch after j matches ; Do not match lps [ 0. . lps [ j - 1 ] ] characters , they will match anyway ; Fills lps [ ] for given pattern pat [ 0. . M - 1 ] ; Length of the previous longest prefix suffix ; lps [ 0 ] is always 0 ; The loop calculates lps [ i ] for i = 1 to M - 1 ; ( pat [ i ] != pat [ len ] ) ; This is tricky . Consider the example . AAACAAAA and i = 7. The idea is similar to search step . ; Returns count of rotations to get the same string back ; Form a string excluding the first character and concatenating the string at the end ; Convert the string to character array ; Use the KMP search algorithm to find it in O ( N ) time ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; void computeLPSArray ( char * pat , int M , int * lps ) ; int KMPSearch ( char * pat , char * txt ) { int M = strlen ( pat ) ; int N = strlen ( txt ) ; int lps [ M ] ; computeLPSArray ( pat , M , lps ) ; int i = 0 ; int j = 0 ; while ( i < N ) { if ( pat [ j ] == txt [ i ] ) { j ++ ; i ++ ; } if ( j == M ) { return i - j ; j = lps [ j - 1 ] ; } else if ( i < N && pat [ j ] != txt [ i ] ) { if ( j != 0 ) j = lps [ j - 1 ] ; else i = i + 1 ; } } } void computeLPSArray ( char * pat , int M , int * lps ) { int len = 0 ; lps [ 0 ] = 0 ; int i = 1 ; while ( i < M ) { if ( pat [ i ] == pat [ len ] ) { len ++ ; lps [ i ] = len ; i ++ ; } else { if ( len != 0 ) { len = lps [ len - 1 ] ; } else { lps [ i ] = 0 ; i ++ ; } } } } int countRotations ( string s ) { string s1 = s . substr ( 1 , s . size ( ) - 1 ) + s ; char pat [ s . length ( ) ] , text [ s1 . length ( ) ] ; strcpy ( pat , s . c_str ( ) ) ; strcpy ( text , s1 . c_str ( ) ) ; return 1 + KMPSearch ( pat , text ) ; } int main ( ) { string s1 = \\\" geeks \\\" ; cout << countRotations ( s1 ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Find K such that changing all elements of the Array greater than K to K will make array sum N | Function to return K such that changing all elements greater than K to K will make array sum N otherwise return - 1 ; Sorting the array in increasing order ; Loop through all the elements of the array ; Checking if sum of array equals N ; Driver code\\\"\\nSolution in Javascript:\",\"targets\":\"function findK ( arr , size , N ) { arr . sort ( function ( a , b ) { return a - b } ) ; let temp_sum = 0 ; for ( let i = 0 ; i < size ; i ++ ) { temp_sum += arr [ i ] ; if ( N - temp_sum == arr [ i ] * ( size - i - 1 ) ) { return arr [ i ] ; } } return - 1 ; } let arr = [ 3 , 1 , 10 , 4 , 8 ] ; let size = arr . length ; let N = 16 ; document . write ( findK ( arr , size , N ) ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Count number of common elements between a sorted array and a reverse sorted array | Function to count the number of elements common in both the arrays ; Used to traverse array A [ ] and B [ ] from the front and the back ; Stores the count of numbers common in both array ; If A [ first ] is less than B [ second ] ; Increment the value of first ; IF B [ second ] is less than A [ first ] ; Decrement the value of second ; A [ first ] is equal to B [ second ] ; Increment the value of count ; Increment the value of first ; Decrement the value of second ; Return the value of count ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def countEqual ( A , B , N ) :\\n\\tfirst = 0\\n\\tsecond = N - 1\\n\\tcount = 0\\n\\twhile ( first < N and second >= 0 ) :\\n\\t\\tif ( A [ first ] < B [ second ] ) :\\n\\t\\t\\tfirst += 1\\n\\t\\telif ( B [ second ] < A [ first ] ) :\\n\\t\\t\\tsecond -= 1\\n\\t\\telse :\\n\\t\\t\\tcount += 1\\n\\t\\t\\tfirst += 1\\n\\t\\t\\tsecond -= 1\\n\\treturn count\\nA = [ 2 , 4 , 5 , 8 , 12 , 13 , 17 , 18 , 20 , 22 , 309 , 999 ]\\nB = [ 109 , 99 , 68 , 54 , 22 , 19 , 17 , 13 , 11 , 5 , 3 , 1 ]\\nN = len ( A )\\nprint ( countEqual ( A , B , N ) )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Dixon 's Factorization Method with implementation | Python 3 implementation of Dixon factorization algo ; Function to find the factors of a number using the Dixon Factorization Algorithm ; Factor base for the given number ; Starting from the ceil of the root of the given number N ; Storing the related squares ; For every number from the square root Till N ; Finding the related squares ; If the two numbers are the related squares , then append them to the array ; For every pair in the array , compute the GCD such that ; If we find a factor other than 1 , then appending it to the final factor array ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"from math import sqrt , gcd\\nimport numpy as np\\ndef factor ( n ) :\\n\\tbase = [ 2 , 3 , 5 , 7 ]\\n\\tstart = int ( sqrt ( n ) )\\n\\tpairs = [ ]\\n\\tfor i in range ( start , n ) :\\n\\t\\tfor j in range ( len ( base ) ) :\\n\\t\\t\\tlhs = i ** 2 % n\\n\\t\\t\\trhs = base [ j ] ** 2 % n\\n\\t\\t\\tif ( lhs == rhs ) :\\n\\t\\t\\t\\tpairs . append ( [ i , base [ j ] ] )\\n\\tnew = [ ]\\n\\tfor i in range ( len ( pairs ) ) :\\n\\t\\tfactor = gcd ( pairs [ i ] [ 0 ] - pairs [ i ] [ 1 ] , n )\\n\\t\\tif ( factor != 1 ) :\\n\\t\\t\\tnew . append ( factor )\\n\\tx = np . array ( new )\\n\\treturn ( np . unique ( x ) )\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tprint ( factor ( 23449 ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Minimum number of squares whose sum equals to given number n | C ++ program for the above approach ; Function to count minimum squares that sum to n ; Creating visited vector of size n + 1 ; Queue of pair to store node and number of steps ; Initially ans variable is initialized with inf ; Push starting node with 0 0 indicate current number of step to reach n ; Mark starting node visited ; If node reaches its destination 0 update it with answer ; Loop for all possible path from 1 to i * i <= current node ( p . first ) ; If we are standing at some node then next node it can jump to will be current node - ( some square less than or equal n ) ; Check if it is valid and not visited yet ; Mark visited ; Push it it Queue ; Return ans to calling function ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int numSquares ( int n ) { vector < int > visited ( n + 1 , 0 ) ; queue < pair < int , int > > q ; int ans = INT_MAX ; q . push ( { n , 0 } ) ; visited [ n ] = 1 ; while ( ! q . empty ( ) ) { pair < int , int > p ; p = q . front ( ) ; q . pop ( ) ; if ( p . first == 0 ) ans = min ( ans , p . second ) ; for ( int i = 1 ; i * i <= p . first ; i ++ ) { int path = ( p . first - ( i * i ) ) ; if ( path >= 0 && ( ! visited [ path ] path == 0 ) ) { visited [ path ] = 1 ; q . push ( { path , p . second + 1 } ) ; } } } return ans ; } int main ( ) { cout << numSquares ( 12 ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Minimum number of palindromic subsequences to be removed to empty a binary string | A function to check if a string str is palindrome ; Start from leftmost and rightmost corners of str ; Keep comparing characters while they are same ; Returns count of minimum palindromic subsequences to be removed to make string empty ; If string is empty ; If string is palindrome ; If string is not palindrome ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function isPalindrome ( $ str ) { $ l = 0 ; $ h = strlen ( $ str ) - 1 ; while ( $ h > $ l ) if ( $ str [ $ l ++ ] != $ str [ $ h -- ] ) return false ; return true ; } function minRemovals ( $ str ) { if ( $ str [ 0 ] == ' ' ) return 0 ; if ( isPalindrome ( $ str ) ) return 1 ; return 2 ; } echo minRemovals ( \\\" 010010 \\\" ) , \\\" \\n \\\" ; echo minRemovals ( \\\" 0100101 \\\" ) , \\\" \\n \\\" ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Count triples with Bitwise AND equal to Zero | Java program for the above approach ; Function to find the number of triplets whose Bitwise AND is 0. ; Stores the count of triplets having bitwise AND equal to 0 ; Stores frequencies of all possible A [ i ] & A [ j ] ; Traverse the array ; Update frequency of Bitwise AND of all array elements with a ; Traverse the array ; Iterate the map ; If bitwise AND of triplet is zero , increment cnt ; Return the number of triplets whose Bitwise AND is 0. ; Driver Code ; Input Array ; Function Call\\\"\\nSolution in Java:\",\"targets\":\"import java . util . * ; class GFG { static int countTriplets ( int [ ] A ) { int cnt = 0 ; HashMap < Integer , Integer > tuples = new HashMap < Integer , Integer > ( ) ; for ( int a : A ) for ( int b : A ) { if ( tuples . containsKey ( a & b ) ) tuples . put ( a & b , tuples . get ( a & b ) + 1 ) ; else tuples . put ( a & b , 1 ) ; } for ( int a : A ) for ( Map . Entry < Integer , Integer > t : tuples . entrySet ( ) ) if ( ( t . getKey ( ) & a ) == 0 ) cnt += t . getValue ( ) ; return cnt ; } public static void main ( String [ ] args ) { int [ ] A = { 2 , 1 , 3 } ; System . out . print ( countTriplets ( A ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Program to check if a matrix is symmetric | Efficient C # code for check a matrix is symmetric or no ; static int MAX = 100 ; Returns true if mat [ N ] [ N ] is symmetric , else false ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static bool isSymmetric ( int [ , ] mat , int N ) { for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) if ( mat [ i , j ] != mat [ j , i ] ) return false ; return true ; } public static void Main ( ) { int [ , ] mat = { { 1 , 3 , 5 } , { 3 , 2 , 4 } , { 5 , 4 , 1 } } ; if ( isSymmetric ( mat , 3 ) ) Console . WriteLine ( \\\" Yes \\\" ) ; else Console . WriteLine ( \\\" NO \\\" ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Print indices of array elements whose removal makes the sum of odd and even | Java program to implement the above approach ; Function to find indices of array elements whose removal makes the sum of odd and even indexed array elements equal ; Stores size of array ; Store prefix sum of odd index array elements ; Store prefix sum of even index array elements ; Update even [ 0 ] ; Traverse the given array ; Update odd [ i ] ; Update even [ i ] ; If the current index is an even number ; Update even [ i ] ; If the current index is an odd number ; Update odd [ i ] ; Check if at least one index found or not that satisfies the condition ; Store odd indices sum by removing 0 - th index ; Store even indices sum by removing 0 - th index ; If p and q are equal ; Traverse the array arr [ ] ; If i is an even number ; Update p by removing the i - th element ; Update q by removing the i - th element ; Update q by removing the i - th element ; Update p by removing the i - th element ; If odd index values sum is equal to even index values sum ; Set the find variable ; Print the current index ; If no index found ; Print not possible ; Driver Code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { static void removeIndicesToMakeSumEqual ( int [ ] arr ) { int N = arr . length ; int [ ] odd = new int [ N ] ; int [ ] even = new int [ N ] ; even [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { odd [ i ] = odd [ i - 1 ] ; even [ i ] = even [ i - 1 ] ; if ( i % 2 == 0 ) { even [ i ] += arr [ i ] ; } else { odd [ i ] += arr [ i ] ; } } boolean find = false ; int p = odd [ N - 1 ] ; int q = even [ N - 1 ] - arr [ 0 ] ; if ( p == q ) { System . out . print ( \\\"0 ▁ \\\" ) ; find = true ; } for ( int i = 1 ; i < N ; i ++ ) { if ( i % 2 == 0 ) { p = even [ N - 1 ] - even [ i - 1 ] - arr [ i ] + odd [ i - 1 ] ; q = odd [ N - 1 ] - odd [ i - 1 ] + even [ i - 1 ] ; } else { q = odd [ N - 1 ] - odd [ i - 1 ] - arr [ i ] + even [ i - 1 ] ; p = even [ N - 1 ] - even [ i - 1 ] + odd [ i - 1 ] ; } if ( p == q ) { find = true ; System . out . print ( i + \\\" ▁ \\\" ) ; } } if ( ! find ) { System . out . print ( - 1 ) ; } } public static void main ( String [ ] args ) { int [ ] arr = { 4 , 1 , 6 , 2 } ; removeIndicesToMakeSumEqual ( arr ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Primality test for the sum of digits at odd places of a number | Java program to do Primality test for the sum of digits at odd places of a number ; Function that return sum of the digits at odd places ; Function that returns true if the number is prime else false ; Corner cases ; This condition is checked so that we can skip middle five numbers in the below loop ; Driver code ; Get the sum of the digits at odd places\\\"\\nSolution in Java:\",\"targets\":\"import java . io . * ; class GFG { static int sum_odd ( int n ) { int sum = 0 , pos = 1 ; while ( n > 0 ) { if ( pos % 2 == 1 ) sum += n % 10 ; n = n \\/ 10 ; pos ++ ; } return sum ; } static boolean check_prime ( 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 ; } public static void main ( String [ ] args ) { int n = 223 ; int sum = sum_odd ( n ) ; if ( check_prime ( sum ) ) System . out . println ( \\\" YES \\\" ) ; else System . out . println ( \\\" NO \\\" ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"Toggle all the bits of a number except k | C program to toggle all bits except kth bit ; Returns a number with all bit toggled in n except k - th bit ; 1 ) Toggle k - th bit by doing n ^ ( 1 << k ) 2 ) Toggle all bits of the modified number ; Driver code\\nHow can the above be solved in C?\",\"targets\":\"#include \\nunsigned int toggleAllExceptK ( unsigned int n , unsigned int k ) { return ~ ( n ^ ( 1 << k ) ) ; } int main ( ) { unsigned int n = 4294967295 ; unsigned int k = 0 ; printf ( \\\" % u \\\" , toggleAllExceptK ( n , k ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Largest number in an array that is not a perfect cube | Python 3 program to find the largest non - perfect cube number among n numbers ; Function to check if a number is perfect cube number or not ; takes the sqrt of the number ; checks if it is a perfect cube number ; Function to find the largest non perfect cube number in the array ; stores the maximum of all perfect cube numbers ; Traverse all elements in the array ; store the maximum if current element is a non perfect cube ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"import math\\ndef checkPerfectcube ( n ) :\\n\\tcube_root = n ** ( 1. \\/ 3. )\\n\\tif round ( cube_root ) ** 3 == n :\\n\\t\\treturn True\\n\\telse :\\n\\t\\treturn False\\ndef largestNonPerfectcubeNumber ( a , n ) :\\n\\tmaxi = - 1\\n\\tfor i in range ( 0 , n , 1 ) :\\n\\t\\tif ( checkPerfectcube ( a [ i ] ) == False ) :\\n\\t\\t\\tmaxi = max ( a [ i ] , maxi )\\n\\treturn maxi\\nif __name__ == ' _ _ main _ _ ' :\\n\\ta = [ 16 , 64 , 25 , 2 , 3 , 10 ]\\n\\tn = len ( a )\\n\\tprint ( largestNonPerfectcubeNumber ( a , n ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Check if a line touches or intersects a circle | PHP program to check if a line touches or intersects or outside a circle . ; Finding the distance of line from center . ; Checking if the distance is less than , greater than or equal to radius . ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function checkCollision ( $ a , $ b , $ c , $ x , $ y , $ radius ) { $ dist = ( abs ( $ a * $ x + $ b * $ y + $ c ) ) \\/ sqrt ( $ a * $ a + $ b * $ b ) ; if ( $ radius == $ dist ) echo \\\" Touch \\\" ; else if ( $ radius > $ dist ) echo \\\" Intersect \\\" ; else echo \\\" Outside \\\" ; } $ radius = 5 ; $ x = 0 ; $ y = 0 ; $ a = 3 ; $ b = 4 ; $ c = 25 ; checkCollision ( $ a , $ b , $ c , $ x , $ y , $ radius ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"Given a HUGE number check if it 's a power of two. | C program to find whether a number is power of 2 or not ; returns 1 when str is power of 2 return 0 when str is not a power of 2 ; sum stores the intermediate dividend while dividing . ; if the input is \\\"1\\\" then return 0 because 2 ^ k = 1 where k >= 1 and here k = 0 ; Divide the number until it gets reduced to 1 if we are successfully able to reduce the number to 1 it means input string is power of two if in between an odd number appears at the end it means string is not divisible by two hence not a power of 2. ; if the last digit is odd then string is not divisible by 2 hence not a power of two return 0. ; divide the whole string by 2. i is used to track index in current number . j is used to track index for next iteration . ; if num < 2 then we have to take another digit to the right of A [ i ] to make it bigger than A [ i ] . E . g . 214 \\/ 2 -- > 107 ; if it 's not the first index. E.g 214 then we have to include 0. ; for eg . \\\"124\\\" we will not write 064 so if it is the first index just ignore ; After every division by 2 the length of string is changed . ; if the string reaches to 1 then the str is a power of 2. ; Driver code .\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#include \\nint isPowerOf2 ( char * str ) { int len_str = strlen ( str ) ; int num = 0 ; if ( len_str == 1 && str [ len_str - 1 ] == '1' ) return 0 ; while ( len_str != 1 str [ len_str - 1 ] != '1' ) { if ( ( str [ len_str - 1 ] - '0' ) % 2 == 1 ) return 0 ; for ( int i = 0 , j = 0 ; i < len_str ; i ++ ) { num = num * 10 + str [ i ] - '0' ; if ( num < 2 ) { if ( i != 0 ) str [ j ++ ] = '0' ; continue ; } str [ j ++ ] = ( int ) ( num \\/ 2 ) + '0' ; num = ( num ) - ( num \\/ 2 ) * 2 ; } str [ j ] = ' \\\\0' ; len_str = j ; } return 1 ; } int main ( ) { char str1 [ ] = \\\"12468462246684202468024\\\" \\\"6842024662202000002\\\" ; char str2 [ ] = \\\"1\\\" ; char str3 [ ] = \\\"128\\\" ; printf ( \\\" % d % d % d \\\" , isPowerOf2 ( str1 ) , isPowerOf2 ( str2 ) , isPowerOf2 ( str3 ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Construct a frequency array of digits of the values obtained from x ^ 1 , x ^ 2 , ... ... . . , x ^ n | C # implementation of above approach ; Function that traverses digits in a number and modifies frequency count array ; Array to keep count of digits ; Traversing through x ^ 1 to x ^ n ; For power function , both its parameters are to be in double ; calling countDigits function on x ^ i ; Printing count of digits 0 - 9 ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static void countDigits ( double val , long [ ] arr ) { while ( ( long ) val > 0 ) { long digit = ( long ) val % 10 ; arr [ ( int ) digit ] ++ ; val = ( long ) val \\/ 10 ; } return ; } static void countFrequency ( int x , int n ) { long [ ] freq_count = new long [ 10 ] ; for ( int i = 1 ; i <= n ; i ++ ) { double val = Math . Pow ( ( double ) x , ( double ) i ) ; countDigits ( val , freq_count ) ; } for ( int i = 0 ; i <= 9 ; i ++ ) { Console . Write ( freq_count [ i ] + \\\" ▁ \\\" ) ; } } public static void Main ( ) { int x = 15 , n = 3 ; countFrequency ( x , n ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Count smaller elements present in the array for each array element | C ++ program for the above approach ; Function to count for each array element , the number of elements that are smaller than that element ; Traverse the array ; Stores the count ; Traverse the array ; Increment count ; Print the count of smaller elements for the current element ; Driver Code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; void smallerNumbers ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { int count = 0 ; for ( int j = 0 ; j < N ; j ++ ) { if ( arr [ j ] < arr [ i ] ) { count ++ ; } } cout << count << \\\" ▁ \\\" ; } } int main ( ) { int arr [ ] = { 3 , 4 , 1 , 1 , 2 } ; int N = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; smallerNumbers ( arr , N ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"NFA to accept strings that has atleast one character occurring in a multiple of 3 | C # implementation of the above approach ; NFA variable that keeps track of the state while transaction . ; This checks for invalid input . ; Function for the state Q2 ; State transitions ' a ' takes to Q4 , and ' b ' and ' c ' remain at Q2 ; Function for the state Q3 ; State transitions ' a ' takes to Q3 , and ' b ' and ' c ' remain at Q4 ; Function for the state Q4 ; State transitions ' a ' takes to Q2 , and ' b ' and ' c ' remain at Q3 ; Function for the state Q5 ; State transitions ' b ' takes to Q6 , and ' a ' and ' c ' remain at Q5 ; Function for the state Q6 ; State transitions ' b ' takes to Q7 , and ' a ' and ' c ' remain at Q7 ; Function for the state Q7 ; State transitions ' b ' takes to Q5 , and ' a ' and ' c ' remain at Q7 ; Function for the state Q8 ; State transitions ' c ' takes to Q9 , and ' a ' and ' b ' remain at Q8 ; Function for the state Q9 ; State transitions ' c ' takes to Q10 , and ' a ' and ' b ' remain at Q9 ; Function for the state Q10 ; State transitions ' c ' takes to Q8 , and ' a ' and ' b ' remain at Q10 ; Function to check for 3 a 's ; Function to check for 3 b 's ; Function to check for 3 c 's ; Driver Code ; If any of the states is true , that is , if either the number of a ' s ▁ or ▁ number ▁ of ▁ b ' s or number of c 's is a multiple of three, then the string is accepted\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int nfa = 1 ; static int flag = 0 ; static void state1 ( char c ) { if ( c == ' a ' ) nfa = 2 ; else if ( c == ' b ' c == ' c ' ) nfa = 1 ; else flag = 1 ; } static void state2 ( char c ) { if ( c == ' a ' ) nfa = 3 ; else if ( c == ' b ' c == ' c ' ) nfa = 2 ; else flag = 1 ; } static void state3 ( char c ) { if ( c == ' a ' ) nfa = 1 ; else if ( c == ' b ' c == ' c ' ) nfa = 3 ; else flag = 1 ; } static void state4 ( char c ) { if ( c == ' b ' ) nfa = 5 ; else if ( c == ' a ' c == ' c ' ) nfa = 4 ; else flag = 1 ; } static void state5 ( char c ) { if ( c == ' b ' ) nfa = 6 ; else if ( c == ' a ' c == ' c ' ) nfa = 5 ; else flag = 1 ; } static void state6 ( char c ) { if ( c == ' b ' ) nfa = 4 ; else if ( c == ' a ' c == ' c ' ) nfa = 6 ; else flag = 1 ; } static void state7 ( char c ) { if ( c == ' c ' ) nfa = 8 ; else if ( c == ' b ' c == ' a ' ) nfa = 7 ; else flag = 1 ; } static void state8 ( char c ) { if ( c == ' c ' ) nfa = 9 ; else if ( c == ' b ' c == ' a ' ) nfa = 8 ; else flag = 1 ; } static void state9 ( char c ) { if ( c == ' c ' ) nfa = 7 ; else if ( c == ' b ' c == ' a ' ) nfa = 9 ; else flag = 1 ; } static bool checkA ( String s , int x ) { for ( int i = 0 ; i < x ; i ++ ) { if ( nfa == 1 ) state1 ( s [ i ] ) ; else if ( nfa == 2 ) state2 ( s [ i ] ) ; else if ( nfa == 3 ) state3 ( s [ i ] ) ; } if ( nfa == 1 ) { return true ; } else { nfa = 4 ; } return false ; } static bool checkB ( String s , int x ) { for ( int i = 0 ; i < x ; i ++ ) { if ( nfa == 4 ) state4 ( s [ i ] ) ; else if ( nfa == 5 ) state5 ( s [ i ] ) ; else if ( nfa == 6 ) state6 ( s [ i ] ) ; } if ( nfa == 4 ) { return true ; } else { nfa = 7 ; } return false ; } static bool checkC ( String s , int x ) { for ( int i = 0 ; i < x ; i ++ ) { if ( nfa == 7 ) state7 ( s [ i ] ) ; else if ( nfa == 8 ) state8 ( s [ i ] ) ; else if ( nfa == 9 ) state9 ( s [ i ] ) ; } if ( nfa == 7 ) { return true ; } return false ; } public static void Main ( String [ ] args ) { String s = \\\" bbbca \\\" ; int x = 5 ; if (...\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Index Mapping ( or Trivial Hashing ) with negatives allowed | C # program to implement direct index mapping with negative values allowed . ; Since array is global , it is initialized as 0. ; searching if X is Present in the given array or not . ; if X is negative take the absolute value of X . ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static int MAX = 1000 ; static bool [ , ] has = new bool [ MAX + 1 , 2 ] ; static bool search ( int X ) { if ( X >= 0 ) { if ( has [ X , 0 ] == true ) { return true ; } else { return false ; } } X = Math . Abs ( X ) ; if ( has [ X , 1 ] == true ) { return true ; } return false ; } static void insert ( int [ ] a , int n ) { for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] >= 0 ) { has [ a [ i ] , 0 ] = true ; } else { has [ Math . Abs ( a [ i ] ) , 1 ] = true ; } } } public static void Main ( ) { int [ ] a = { - 1 , 9 , - 5 , - 8 , - 5 , - 2 } ; int n = a . Length ; insert ( a , n ) ; int X = - 5 ; if ( search ( X ) == true ) { Console . WriteLine ( \\\" Present \\\" ) ; } else { Console . WriteLine ( \\\" Not ▁ Present \\\" ) ; } } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Longest Common Subsequence | DP using Memoization | Javascript program to memoize recursive implementation of LCS problem ; Returns length of LCS for X [ 0. . m - 1 ] , Y [ 0. . n - 1 ] memoization applied in recursive solution ; base case ; if the same state has already been computed ; if equal , then we store the value of the function call ; store it in arr to avoid further repetitive work in future function calls ; store it in arr to avoid further repetitive work in future function calls ; Driver Code ; assign - 1 to all positions\\\"\\nHow can the above be solved in JS?\",\"targets\":\"let maximum = 1000 ; function lcs ( X , Y , m , n , dp ) { if ( m == 0 n == 0 ) { return 0 ; } if ( dp [ m - 1 ] [ n - 1 ] != - 1 ) { return dp [ m - 1 ] [ n - 1 ] ; } if ( X [ m - 1 ] == Y [ n - 1 ] ) { dp [ m - 1 ] [ n - 1 ] = 1 + lcs ( X , Y , m - 1 , n - 1 , dp ) ; return dp [ m - 1 ] [ n - 1 ] ; } else { dp [ m - 1 ] [ n - 1 ] = Math . max ( lcs ( X , Y , m , n - 1 , dp ) , lcs ( X , Y , m - 1 , n , dp ) ) ; return dp [ m - 1 ] [ n - 1 ] ; } } let X = \\\" \\\" ; let Y = \\\" \\\" ; let m = X . length ; let n = Y . length ; let dp = new Array ( m ) ; for ( let i = 0 ; i < dp . length ; i ++ ) { dp [ i ] = new Array ( maximum ) ; for ( let j = 0 ; j < dp [ i ] . length ; j ++ ) { dp [ i ] [ j ] = - 1 ; } } document . write ( \\\" \\\" + lcs ( X , Y , m , n , dp ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Subset Sum Problem in O ( sum ) space | Returns true if there exists a subset with given sum in arr [ ] ; The value of subset [ i % 2 ] [ j ] will be true if there exists a subset of sum j in arr [ 0 , 1 , ... . , i - 1 ] ; A subset with sum 0 is always possible ; If there exists no element no sum is possible ; Driver code\\\"\\nSolution in C:\",\"targets\":\"#include \\n#include \\nbool isSubsetSum ( int arr [ ] , int n , int sum ) { bool subset [ 2 ] [ sum + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= sum ; j ++ ) { if ( j == 0 ) subset [ i % 2 ] [ j ] = true ; else if ( i == 0 ) subset [ i % 2 ] [ j ] = false ; else if ( arr [ i - 1 ] <= j ) subset [ i % 2 ] [ j ] = subset [ ( i + 1 ) % 2 ] [ j - arr [ i - 1 ] ] || subset [ ( i + 1 ) % 2 ] [ j ] ; else subset [ i % 2 ] [ j ] = subset [ ( i + 1 ) % 2 ] [ j ] ; } } return subset [ n % 2 ] [ sum ] ; } int main ( ) { int arr [ ] = { 6 , 2 , 5 } ; int sum = 7 ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; if ( isSubsetSum ( arr , n , sum ) == true ) printf ( \\\" There ▁ exists ▁ a ▁ subset ▁ with ▁ given ▁ sum \\\" ) ; else printf ( \\\" No ▁ subset ▁ exists ▁ with ▁ given ▁ sum \\\" ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Absolute difference between the count of odd and even factors of N | Function to find the smallest prime factor of all the numbers using Sieve Of Eratosthenes ; Stores whether any number is prime or not ; Initialize smallest factor as 2 for all the even numbers ; Iterate over the range [ 3 , N ] ; If i is prime ; Iterate all multiples of i ; i is the smallest prime factor of i * j ; Function to find the absolute difference between the count of odd and even factors of N ; Stores the smallest prime factor of i ; Fill values in s [ ] using sieve of eratosthenes ; Stores the total number of factors and the total number of odd and even factors ; Store the current prime factor of the number N ; Store the power of current prime factor ; Loop while N is greater than 1 ; If N also has smallest prime factor as curr , then increment cnt by 1 ; Update only total number of factors if curr is 2 ; Update total number of factors and total number of odd factors ; Update current prime factor as s [ N ] and count as 1 ; Calculate the number of even factors ; Print the difference ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def sieveOfEratosthenes ( N , s ) :\\n\\tprime = [ False ] * ( N + 1 )\\n\\tfor i in range ( 2 , N + 1 , 2 ) :\\n\\t\\ts [ i ] = 2\\n\\tfor i in range ( 3 , N , 2 ) :\\n\\t\\tif ( prime [ i ] == False ) :\\n\\t\\t\\ts [ i ] = i\\n\\t\\t\\tfor j in range ( i , N , 2 ) :\\n\\t\\t\\t\\tif j * i > N :\\n\\t\\t\\t\\t\\tbreak\\n\\t\\t\\t\\tif ( not prime [ i * j ] ) :\\n\\t\\t\\t\\t\\tprime [ i * j ] = True\\n\\t\\t\\t\\t\\ts [ i * j ] = i\\ndef findDifference ( N ) :\\n\\ts = [ 0 ] * ( N + 1 )\\n\\tsieveOfEratosthenes ( N , s )\\n\\ttotal , odd , even = 1 , 1 , 0\\n\\tcurr = s [ N ]\\n\\tcnt = 1\\n\\twhile ( N > 1 ) :\\n\\t\\tN \\/\\/= s [ N ]\\n\\t\\tif ( curr == s [ N ] ) :\\n\\t\\t\\tcnt += 1\\n\\t\\t\\tcontinue\\n\\t\\tif ( curr == 2 ) :\\n\\t\\t\\ttotal = total * ( cnt + 1 )\\n\\t\\telse :\\n\\t\\t\\ttotal = total * ( cnt + 1 )\\n\\t\\t\\todd = odd * ( cnt + 1 )\\n\\t\\tcurr = s [ N ]\\n\\t\\tcnt = 1\\n\\teven = total - odd\\n\\tprint ( abs ( even - odd ) )\\nif __name__ == ' _ _ main _ _ ' :\\n\\tN = 12\\n\\tfindDifference ( N )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Print the nodes at odd levels of a tree | Iterative Python3 program to prodd level nodes A Binary Tree Node Utility function to create a new tree Node ; Iterative method to do level order traversal line by line ; Base Case ; Create an empty queue for level order traversal ; Enqueue root and initialize level as odd ; nodeCount ( queue size ) indicates number of nodes at current level . ; Dequeue all nodes of current level and Enqueue all nodes of next level ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"class newNode :\\n\\tdef __init__ ( self , data ) :\\n\\t\\tself . data = data\\n\\t\\tself . left = self . right = None\\ndef printOddNodes ( root ) :\\n\\tif ( root == None ) :\\n\\t\\treturn\\n\\tq = [ ]\\n\\tq . append ( root )\\n\\tisOdd = True\\n\\twhile ( 1 ) :\\n\\t\\tnodeCount = len ( q )\\n\\t\\tif ( nodeCount == 0 ) :\\n\\t\\t\\tbreak\\n\\t\\twhile ( nodeCount > 0 ) :\\n\\t\\t\\tnode = q [ 0 ]\\n\\t\\t\\tif ( isOdd ) :\\n\\t\\t\\t\\tprint ( node . data , end = \\\" ▁ \\\" )\\n\\t\\t\\tq . pop ( 0 )\\n\\t\\t\\tif ( node . left != None ) :\\n\\t\\t\\t\\tq . append ( node . left )\\n\\t\\t\\tif ( node . right != None ) :\\n\\t\\t\\t\\tq . append ( node . right )\\n\\t\\t\\tnodeCount -= 1\\n\\t\\tisOdd = not isOdd\\nif __name__ == ' _ _ main _ _ ' :\\n\\troot = newNode ( 1 )\\n\\troot . left = newNode ( 2 )\\n\\troot . right = newNode ( 3 )\\n\\troot . left . left = newNode ( 4 )\\n\\troot . left . right = newNode ( 5 )\\n\\tprintOddNodes ( root )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Check if given number is a power of d where d is a power of 2 | PHP program to find if a number is power of d where d is power of 2. ; Function to count the number of ways to paint N * 3 grid based on given conditions ; Check if there is only one bit set in n ; count 0 bits before set bit ; If count is a multiple of log2 ( d ) then return true else false ; If there are more than 1 bit set then n is not a power of 4 ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function Log2n ( $ n ) { return ( $ n > 1 ) ? 1 + Log2n ( $ n \\/ 2 ) : 0 ; } function isPowerOfd ( $ n , $ d ) { $ count = 0 ; if ( $ n && ! ( $ n & ( $ n - 1 ) ) ) { while ( $ n > 1 ) { $ n >>= 1 ; $ count += 1 ; } return ( $ count % ( Log2n ( $ d ) ) == 0 ) ; } return false ; } $ n = 64 ; $ d = 8 ; if ( isPowerOfd ( $ n , $ d ) ) echo $ n , \\\" ▁ \\\" , \\\" is ▁ a ▁ power ▁ of ▁ \\\" , $ d ; else echo $ n , \\\" ▁ \\\" , \\\" is ▁ not ▁ a ▁ power ▁ of ▁ \\\" , $ d ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Minimum insertions to form a palindrome | DP | Recursive function to find minimum number of insertions ; Base Cases ; Check if the first and last characters are same . On the basis of the comparison result , decide which subrpoblem ( s ) to call ; Driver program to test above functions\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function findMinInsertions ( str , l , h ) { if ( l > h ) return Number . MAX_VALUE ; if ( l == h ) return 0 ; if ( l == h - 1 ) return ( str [ l ] == str [ h ] ) ? 0 : 1 ; return ( str [ l ] == str [ h ] ) ? findMinInsertions ( str , l + 1 , h - 1 ) : ( Math . min ( findMinInsertions ( str , l , h - 1 ) , findMinInsertions ( str , l + 1 , h ) ) + 1 ) } let str = \\\" \\\" ; document . write ( findMinInsertions ( str , 0 , str . length - 1 ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Find an integer in the given range that satisfies the given conditions | C ++ implementation of the approach ; Function that returns true if x contains all distinct digits ; Last digit of x ; If current digit has appeared before ; Mark the current digit to present ; Remove the last digit ; Function to return the required value of k ; To store the maximum value for the given expression ; If i contains all distinct digits ; If the value of the expression is also maximum then update k and the expression ; Driver code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; const int MAX = 10 ; bool distinctDigits ( int x ) { bool present [ MAX ] = { false } ; while ( x > 0 ) { int digit = x % 10 ; if ( present [ digit ] ) return false ; present [ digit ] = true ; x \\/= 10 ; } return true ; } int findK ( int l , int r ) { int maxExp = INT_MIN ; int k = -1 ; for ( int i = l ; i <= r ; i ++ ) { if ( distinctDigits ( i ) ) { int exp = ( l - i ) * ( i - r ) ; if ( exp >= maxExp ) { k = i ; maxExp = exp ; } } } return k ; } int main ( ) { int l = 50 , r = 60 ; cout << findK ( l , r ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Binary Insertion Sort | iterative implementation ; Function to sort an array a [ ] of size ' n ' ; find location where selected should be inseretd ; Move all elements after location to create space ; Driver Code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function binarySearch ( a , item , low , high ) { while ( low <= high ) { var mid = low + ( high - low ) \\/ 2 ; if ( item == a [ mid ] ) return mid + 1 ; else if ( item > a [ mid ] ) low = mid + 1 ; else high = mid - 1 ; } return low ; } function insertionSort ( a , n ) { var i , loc , j , k , selected ; for ( i = 1 ; i < n ; ++ i ) { j = i - 1 ; selected = a [ i ] ; loc = binarySearch ( a , selected , 0 , j ) ; while ( j >= loc ) { a [ j + 1 ] = a [ j ] ; j -- ; } a [ j + 1 ] = selected ; } } var a = [ 37 , 23 , 0 , 17 , 12 , 72 , 31 , 46 , 100 , 88 , 54 ] ; var n = a . length , i ; insertionSort ( a , n ) ; document . write ( \\\" \\\" + \\\" \\\" ) ; for ( i = 0 ; i < n ; i ++ ) document . write ( a [ i ] + \\\" \\\" ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Minimum cells required to reach destination with jumps equal to cell values | Python3 implementation to count minimum cells required to be covered to reach destination ; function to count minimum cells required to be covered to reach destination ; to store min cells required to be covered to reach a particular cell ; base case ; building up the dp [ ] [ ] matrix ; dp [ i ] [ j ] != MAX denotes that cell ( i , j ) can be reached from cell ( 0 , 0 ) and the other half of the condition finds the cell on the right that can be reached from ( i , j ) ; the other half of the condition finds the cell right below that can be reached from ( i , j ) ; it true then cell ( m - 1 , n - 1 ) can be reached from cell ( 0 , 0 ) and returns the minimum number of cells covered ; cell ( m - 1 , n - 1 ) cannot be reached from cell ( 0 , 0 ) ; Driver program to test above\\\"\\nHow can the above be solved in Python?\",\"targets\":\"SIZE = 100\\nMAX = 10000000\\ndef minCells ( mat , m , n ) :\\n\\tdp = [ [ MAX for i in range ( n ) ] for i in range ( m ) ]\\n\\tdp [ 0 ] [ 0 ] = 1\\n\\tfor i in range ( m ) :\\n\\t\\tfor j in range ( n ) :\\n\\t\\t\\tif ( dp [ i ] [ j ] != MAX and ( j + mat [ i ] [ j ] ) < n and ( dp [ i ] [ j ] + 1 ) < dp [ i ] [ j + mat [ i ] [ j ] ] ) :\\n\\t\\t\\t\\tdp [ i ] [ j + mat [ i ] [ j ] ] = dp [ i ] [ j ] + 1\\n\\t\\t\\tif ( dp [ i ] [ j ] != MAX and ( i + mat [ i ] [ j ] ) < m and ( dp [ i ] [ j ] + 1 ) < dp [ i + mat [ i ] [ j ] ] [ j ] ) :\\n\\t\\t\\t\\tdp [ i + mat [ i ] [ j ] ] [ j ] = dp [ i ] [ j ] + 1\\n\\tif ( dp [ m - 1 ] [ n - 1 ] != MAX ) :\\n\\t\\treturn dp [ m - 1 ] [ n - 1 ]\\n\\treturn - 1\\nmat = [ [ 2 , 3 , 2 , 1 , 4 ] , [ 3 , 2 , 5 , 8 , 2 ] , [ 1 , 1 , 2 , 2 , 1 ] ]\\nm = 3\\nn = 5\\nprint ( \\\" Minimum ▁ number ▁ of ▁ cells ▁ = ▁ \\\" , minCells ( mat , m , n ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Sparse Table | C # program to do range minimum query using sparse table ; lookup [ i , j ] is going to store GCD of arr [ i . . j ] . Ideally lookup table size should not be fixed and should be determined using n Log n . It is kept constant to keep code simple . ; it builds sparse table . ; GCD of single element is element itself ; Build sparse table ; Returns GCD of arr [ L . . R ] ; Find highest power of 2 that is smaller than or equal to count of elements in given range . For [ 2 , 10 ] , j = 3 ; Compute GCD of last 2 ^ j elements with first 2 ^ j elements in range . For [ 2 , 10 ] , we find GCD of arr [ lookup [ 0 , 3 ] ] and arr [ lookup [ 3 , 3 ] ] , ; Driver Code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static readonly int MAX = 500 ; static int [ , ] table = new int [ MAX , MAX ] ; static void buildSparseTable ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) table [ i , 0 ] = arr [ i ] ; for ( int j = 1 ; j <= n ; j ++ ) for ( int i = 0 ; i <= n - ( 1 << j ) ; i ++ ) table [ i , j ] = __gcd ( table [ i , j - 1 ] , table [ i + ( 1 << ( j - 1 ) ) , j - 1 ] ) ; } static int query ( int L , int R ) { int j = ( int ) Math . Log ( R - L + 1 ) ; return __gcd ( table [ L , j ] , table [ R - ( 1 << j ) + 1 , j ] ) ; } static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } public static void Main ( String [ ] args ) { int [ ] a = { 7 , 2 , 3 , 0 , 5 , 10 , 3 , 12 , 18 } ; int n = a . Length ; buildSparseTable ( a , n ) ; Console . Write ( query ( 0 , 2 ) + \\\" \\n \\\" ) ; Console . Write ( query ( 1 , 3 ) + \\\" \\n \\\" ) ; Console . Write ( query ( 4 , 5 ) + \\\" \\n \\\" ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Sum of all odd length palindromic numbers within the range [ L , R ] | Function that returns true if the given number is a palindrome ; Here we are generating a new number ( reverse_num ) by reversing the digits of original input number ; If the original input number ( num ) is equal to its reverse ( reverse_num ) then its palindrome else it is not . ; Function that returns true if the given number is of odd length ; Function to return the sum of all odd length palindromic numbers within the given range ; if number is palindrome and of odd length ; Driver code\\\"\\nSolution in php:\",\"targets\":\"< ? php function isPalindrome ( $ num ) { $ reverse_num = 0 ; $ remainder ; $ temp ; $ temp = $ num ; while ( $ temp != 0 ) { $ remainder = $ temp % 10 ; $ reverse_num = $ reverse_num * 10 + $ remainder ; $ temp = ( int ) ( $ temp \\/ 10 ) ; } if ( $ reverse_num == $ num ) { return true ; } return false ; } function isOddLength ( $ num ) { $ count = 0 ; while ( $ num > 0 ) { $ num = ( int ) ( $ num \\/ 10 ) ; $ count ++ ; } if ( $ count % 2 != 0 ) { return true ; } return false ; } function sumOfAllPalindrome ( $ L , $ R ) { $ sum = 0 ; if ( $ L <= $ R ) for ( $ i = $ L ; $ i <= $ R ; $ i ++ ) { if ( isPalindrome ( $ i ) && isOddLength ( $ i ) ) { $ sum += $ i ; } } return $ sum ; } $ L = 110 ; $ R = 1130 ; echo sumOfAllPalindrome ( $ L , $ R ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"D Numbers | C # implementation for the above approach ; Function to find the N - th icosikaipentagon number ; Number should be greater than 3 ; Check every k in range 2 to n - 1 ; Condition for D - Number ; Driver Code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static bool isDNum ( int n ) { if ( n < 4 ) return false ; int numerator = 0 , hcf = 0 ; for ( int k = 2 ; k <= n ; k ++ ) { numerator = ( int ) ( Math . Pow ( k , n - 2 ) - k ) ; hcf = __gcd ( n , k ) ; } if ( hcf == 1 && ( numerator % n ) != 0 ) return false ; return true ; } static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } public static void Main ( String [ ] args ) { int n = 15 ; bool a = isDNum ( n ) ; if ( a ) Console . Write ( \\\" Yes \\\" ) ; else Console . Write ( \\\" No \\\" ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Dynamic Programming | A Dynamic Programming solution for subset sum problem ; Returns true if there is a subset of set [ ] with sum equal to given sum ; The value of subset [ i ] [ j ] will be true if there is a subset of set [ 0. . j - 1 ] with sum equal to i ; If sum is 0 , then answer is true ; If sum is not 0 and set is empty , then answer is false ; Fill the subset table in bottom up manner ; uncomment this code to print table ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; bool isSubsetSum ( int set [ ] , int n , int sum ) { bool subset [ n + 1 ] [ sum + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) subset [ i ] [ 0 ] = true ; for ( int i = 1 ; i <= sum ; i ++ ) subset [ 0 ] [ i ] = false ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= sum ; j ++ ) { if ( j < set [ i - 1 ] ) subset [ i ] [ j ] = subset [ i - 1 ] [ j ] ; if ( j >= set [ i - 1 ] ) subset [ i ] [ j ] = subset [ i - 1 ] [ j ] || subset [ i - 1 ] [ j - set [ i - 1 ] ] ; } } for ( int i = 0 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= sum ; j ++ ) printf ( \\\" % 4d \\\" , subset [ i ] [ j ] ) ; cout << \\\" \\n \\\" ; } return subset [ n ] [ sum ] ; } int main ( ) { int set [ ] = { 3 , 34 , 4 , 12 , 5 , 2 } ; int sum = 9 ; int n = sizeof ( set ) \\/ sizeof ( set [ 0 ] ) ; if ( isSubsetSum ( set , n , sum ) == true ) cout << \\\" Found ▁ a ▁ subset ▁ with ▁ given ▁ sum \\\" ; else cout << \\\" No ▁ subset ▁ with ▁ given ▁ sum \\\" ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Maximum equlibrium sum in an array | Java program to find maximum equilibrium sum . ; Function to find maximum equilibrium sum . ; Driver Code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . lang . Math . * ; import java . util . stream . * ; class GFG { static int findMaxSum ( int arr [ ] , int n ) { int sum = IntStream . of ( arr ) . sum ( ) ; int prefix_sum = 0 , res = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { prefix_sum += arr [ i ] ; if ( prefix_sum == sum ) res = Math . max ( res , prefix_sum ) ; sum -= arr [ i ] ; } return res ; } public static void main ( String [ ] args ) { int arr [ ] = { - 2 , 5 , 3 , 1 , 2 , 6 , - 4 , 2 } ; int n = arr . length ; System . out . print ( findMaxSum ( arr , n ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Maximum triplet sum in array | Java code to find maximum triplet sum ; This function assumes that there are at least three elements in arr [ ] . ; Initialize Maximum , second maximum and third maximum element ; Update Maximum , second maximum and third maximum element ; Update second maximum and third maximum element ; Update third maximum element ; Driven code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . io . * ; import java . util . * ; class GFG { static int maxTripletSum ( int arr [ ] , int n ) { int maxA = - 100000000 , maxB = - 100000000 ; int maxC = - 100000000 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > maxA ) { maxC = maxB ; maxB = maxA ; maxA = arr [ i ] ; } else if ( arr [ i ] > maxB ) { maxC = maxB ; maxB = arr [ i ] ; } else if ( arr [ i ] > maxC ) maxC = arr [ i ] ; } return ( maxA + maxB + maxC ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 0 , 8 , 6 , 4 , 2 } ; int n = arr . length ; System . out . println ( maxTripletSum ( arr , n ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Print Binary Tree in 2 | Java Program to print binary tree in 2D ; A binary tree node ; Constructor that allocates a new node with the given data and null left and right pointers . ; Function to print binary tree in 2D It does reverse inorder traversal ; Base case ; Increase distance between levels ; Process right child first ; Print current node after space count ; Process left child ; Wrapper over print2DUtil ( ) ; Pass initial space count as 0 ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"class GFG { static final int COUNT = 10 ; static class Node { int data ; Node left , right ; Node ( int data ) { this . data = data ; this . left = null ; this . right = null ; } } ; static void print2DUtil ( Node root , int space ) { if ( root == null ) return ; space += COUNT ; print2DUtil ( root . right , space ) ; System . out . print ( \\\"\\n\\\"); for ( int i = COUNT ; i < space ; i ++ ) System . out . print ( \\\" ▁ \\\" ) ; System . out . print ( root . data + \\\"\\n\\\"); print2DUtil ( root . left , space ) ; } static void print2D ( Node root ) { print2DUtil ( root , 0 ) ; } public static void main ( String args [ ] ) { Node root = new Node ( 1 ) ; root . left = new Node ( 2 ) ; root . right = new Node ( 3 ) ; root . left . left = new Node ( 4 ) ; root . left . right = new Node ( 5 ) ; root . right . left = new Node ( 6 ) ; root . right . right = new Node ( 7 ) ; root . left . left . left = new Node ( 8 ) ; root . left . left . right = new Node ( 9 ) ; root . left . right . left = new Node ( 10 ) ; root . left . right . right = new Node ( 11 ) ; root . right . left . left = new Node ( 12 ) ; root . right . left . right = new Node ( 13 ) ; root . right . right . left = new Node ( 14 ) ; root . right . right . right = new Node ( 15 ) ; print2D ( root ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Probability of rain on N + 1 th day | Function to find the probability ; count 1 ; find probability ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function rainDayProbability ( $ a , $ n ) { $ count = 0 ; $ m ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { if ( $ a [ $ i ] == 1 ) $ count ++ ; } $ m = $ count \\/ $ n ; return $ m ; } $ a = array ( 1 , 0 , 1 , 0 , 1 , 1 , 1 , 1 ) ; $ n = count ( $ a ) ; echo rainDayProbability ( $ a , $ n ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Minimum operations required to make all elements in an array of first N odd numbers equal | Function to find the minimum number of operations required to make the array elements equal ; If the value of N is even ; Return the value ; Otherwise , N is odd ; Return the value ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def minOperation ( N ) :\\n\\tif ( N % 2 == 0 ) :\\n\\t\\treturn ( N \\/ 2 ) * ( N \\/ 2 )\\n\\tk = ( N - 1 ) \\/ 2\\n\\treturn ( k * ( k + 1 ) )\\nN = 6\\nprint ( int ( minOperation ( N ) ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Program to find area of a Trapezoid | C ++ program to calculate area of a trapezoid ; Function for the area ; Driver Code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; double Area ( int b1 , int b2 , int h ) { return ( ( b1 + b2 ) \\/ 2 ) * h ; } int main ( ) { int base1 = 8 , base2 = 10 , height = 6 ; double area = Area ( base1 , base2 , height ) ; cout << \\\" Area ▁ is : ▁ \\\" << area ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Maximum determinant of a matrix with every values either 0 or n | Java program to find maximum possible determinant of 0 \\/ n matrix . ; Function for maximum determinant ; Function to print resulatant matrix ; three position where 0 appears ; position where n appears ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"import java . io . * ; public class GFG { static int maxDet ( int n ) { return ( 2 * n * n * n ) ; } void resMatrix ( int n ) { for ( int i = 0 ; i < 3 ; i ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { if ( i == 0 && j == 2 ) System . out . print ( \\\"0 ▁ \\\" ) ; else if ( i == 1 && j == 0 ) System . out . print ( \\\"0 ▁ \\\" ) ; else if ( i == 2 && j == 1 ) System . out . print ( \\\"0 ▁ \\\" ) ; else System . out . print ( n + \\\" ▁ \\\" ) ; } System . out . println ( \\\" \\\" ) ; } } static public void main ( String [ ] args ) { int n = 15 ; GFG geeks = new GFG ( ) ; System . out . println ( \\\" Maximum ▁ Determinant ▁ = ▁ \\\" + maxDet ( n ) ) ; System . out . println ( \\\" Resultant ▁ Matrix ▁ : \\\" ) ; geeks . resMatrix ( n ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Longest Common Substring ( Space optimized DP solution ) | Space optimized CPP implementation of longest common substring . ; Function to find longest common substring . ; Find length of both the strings . ; Variable to store length of longest common substring . ; Matrix to store result of two consecutive rows at a time . ; Variable to represent which row of matrix is current row . ; For a particular value of i and j , len [ currRow ] [ j ] stores length of longest common substring in string X [ 0. . i ] and Y [ 0. . j ] . ; Make current row as previous row and previous row as new current row . ; Driver Code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . io . * ; import java . util . * ; public class GFG { static int LCSubStr ( String X , String Y ) { int m = X . length ( ) ; int n = Y . length ( ) ; int result = 0 ; int [ ] [ ] len = new int [ 2 ] [ n ] ; int currRow = 0 ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i == 0 j == 0 ) { len [ currRow ] [ j ] = 0 ; } else if ( X . charAt ( i - 1 ) == Y . charAt ( j - 1 ) ) { len [ currRow ] [ j ] = len [ ( 1 - currRow ) ] [ ( j - 1 ) ] + 1 ; result = Math . max ( result , len [ currRow ] [ j ] ) ; } else { len [ currRow ] [ j ] = 0 ; } } currRow = 1 - currRow ; } return result ; } public static void main ( String args [ ] ) { String X = \\\" GeeksforGeeks \\\" ; String Y = \\\" GeeksQuiz \\\" ; System . out . print ( LCSubStr ( X , Y ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Sum of minimum element of all subarrays of a sorted array | Function to find the sum of minimum of all subarrays ; Driver code\\\"\\nSolution in Javascript:\",\"targets\":\"function findMinSum ( arr , n ) { var sum = 0 ; for ( var i = 0 ; i < n ; i ++ ) sum += arr [ i ] * ( n - i ) ; return sum ; } var arr = [ 3 , 5 , 7 , 8 ] ; var n = arr . length ; document . write ( findMinSum ( arr , n ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Sum of first N natural numbers which are divisible by X or Y | Function to calculate the sum of numbers divisible by X or Y ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function sum ( $ N , $ X , $ Y ) { $ S1 ; $ S2 ; $ S3 ; $ S1 = floor ( ( ( int ) $ N \\/ $ X ) ) * ( 2 * $ X + ( int ) ( ( int ) $ N \\/ $ X - 1 ) * $ X ) \\/ 2 ; $ S2 = floor ( ( ( int ) $ N \\/ $ Y ) ) * ( 2 * $ Y + ( int ) ( ( int ) $ N \\/ $ Y - 1 ) * $ Y ) \\/ 2 ; $ S3 = floor ( ( ( int ) $ N \\/ ( $ X * $ Y ) ) ) * ( 2 * ( $ X * $ Y ) + ( ( int ) $ N \\/ ( $ X * $ Y ) - 1 ) * ( int ) ( $ X * $ Y ) ) \\/ 2 ; return ceil ( $ S1 + ( $ S2 - $ S3 ) ) ; } $ N = 14 ; $ X = 3 ; $ Y = 5 ; echo sum ( $ N , $ X , $ Y ) ; #This code is contributed by ajit.\\n? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Sentence Case of a given Camel cased string | Java implementation of the approach ; Function to return the original string after converting it back from camelCase ; Print the first character as it is ; Traverse the rest of the characters one by one ; If current character is uppercase print space followed by the current character in lowercase ; Else print the current character ; Driver code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"class GFG { static void getOrgString ( String s ) { System . out . print ( s . charAt ( 0 ) ) ; int i = 1 ; while ( i < s . length ( ) ) { if ( s . charAt ( i ) >= ' A ' && s . charAt ( i ) <= ' Z ' ) System . out . print ( \\\" ▁ \\\" + Character . toLowerCase ( s . charAt ( i ) ) ) ; else System . out . print ( s . charAt ( i ) ) ; i ++ ; } } public static void main ( String [ ] args ) { String s = \\\" ILoveGeeksForGeeks \\\" ; getOrgString ( s ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Smallest number exceeding N whose Kth bit is set | Java program for the above approach ; Function to find the number greater than n whose Kth bit is set ; Iterate from N + 1 ; Check if Kth bit is set or not ; Increment M for next number ; Return the minimum value ; Driver Code ; Given N and K ; Function Call\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { static int find_next ( int n , int k ) { int M = n + 1 ; while ( true ) { if ( ( M & ( 1L << k ) ) > 0 ) break ; M ++ ; } return M ; } public static void main ( String [ ] args ) { int N = 15 , K = 2 ; System . out . print ( find_next ( N , K ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"Write a program to calculate pow ( x , n ) | Function to calculate x raised to the power y in O ( logn )\\nHow can the above be solved in C?\",\"targets\":\"int power ( int x , unsigned int y ) { int temp ; if ( y == 0 ) return 1 ; temp = power ( x , y \\/ 2 ) ; if ( y % 2 == 0 ) return temp * temp ; else return x * temp * temp ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Check if a circle lies inside another circle or not | Java program to check if one circle lies inside another circle or not . ; Driver code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . io . * ; class GFG { static void circle ( int x1 , int y1 , int x2 , int y2 , int r1 , int r2 ) { int distSq = ( int ) Math . sqrt ( ( ( x1 - x2 ) * ( x1 - x2 ) ) + ( ( y1 - y2 ) * ( y1 - y2 ) ) ) ; if ( distSq + r2 == r1 ) { System . out . println ( \\\" The ▁ smaller ▁ circle ▁ lies ▁ completely \\\" + \\\" ▁ inside ▁ the ▁ bigger ▁ circle ▁ with ▁ \\\" + \\\" touching ▁ each ▁ other ▁ \\\" + \\\" at ▁ a ▁ point ▁ of ▁ circumference . ▁ \\\" ) ; } else if ( distSq + r2 < r1 ) { System . out . println ( \\\" The ▁ smaller ▁ circle ▁ lies ▁ completely \\\" + \\\" ▁ inside ▁ the ▁ bigger ▁ circle ▁ without \\\" + \\\" ▁ touching ▁ each ▁ other ▁ \\\" + \\\" at ▁ a ▁ point ▁ of ▁ circumference . \\\" ) ; } else { System . out . println ( \\\" The ▁ smaller ▁ does ▁ not ▁ lies ▁ inside \\\" + \\\" ▁ the ▁ bigger ▁ circle ▁ completely . \\\" ) ; } } public static void main ( String [ ] args ) { int x1 = 10 , y1 = 8 ; int x2 = 1 , y2 = 2 ; int r1 = 30 , r2 = 10 ; circle ( x1 , y1 , x2 , y2 , r1 , r2 ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Middle of three using minimum comparisons | Function to find the middle of three numbers ; Compare each three number to find middle number . Enter only if a > b ; Decided a is not greater than b . ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function middleOfThree ( $ a , $ b , $ c ) { if ( $ a > $ b ) { if ( $ b > $ c ) return $ b ; else if ( $ a > $ c ) return $ c ; else return $ a ; } else { if ( $ a > $ c ) return $ a ; else if ( $ b > $ c ) return $ c ; else return $ b ; } } $ a = 20 ; $ b = 30 ; $ c = 40 ; echo middleOfThree ( $ a , $ b , $ c ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Program to find the Volume of an irregular tetrahedron | Java implementation of above approach ; Function to find the volume ; Steps to calculate volume of a Tetrahedron using formula ; Driver code ; edge lengths\\\"\\nSolution in Java:\",\"targets\":\"import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static void findVolume ( double u , double v , double w , double U , double V , double W , double b ) { double uPow = Math . pow ( u , 2 ) ; double vPow = Math . pow ( v , 2 ) ; double wPow = Math . pow ( w , 2 ) ; double UPow = Math . pow ( U , 2 ) ; double VPow = Math . pow ( V , 2 ) ; double WPow = Math . pow ( W , 2 ) ; double a = 4 * ( uPow * vPow * wPow ) - uPow * Math . pow ( ( vPow + wPow - UPow ) , 2 ) - vPow * Math . pow ( ( wPow + uPow - VPow ) , 2 ) - wPow * Math . pow ( ( uPow + vPow - WPow ) , 2 ) + ( vPow + wPow - UPow ) * ( wPow + uPow - VPow ) * ( uPow + vPow - WPow ) ; double vol = Math . sqrt ( a ) ; vol \\/= b ; System . out . printf ( \\\" % .4f \\\" , vol ) ; } public static void main ( String args [ ] ) { double u = 1000 , v = 1000 , w = 1000 ; double U = 3 , V = 4 , W = 5 ; double b = 12 ; findVolume ( u , v , w , U , V , W , b ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Bessel 's Interpolation | Calculating u mentioned in the formula ; Calculating factorial of given number n ; Number of values given ; y is used for difference table with y [ 0 ] used for input ; Calculating the central difference table ; Displaying the central difference table ; Value to interpolate at ; Initializing u and sum ; k is origin thats is f ( 0 ) ; Origin for odd ; Origin for even ; Solving using bessel 's formula\\\"\\nSolution in Javascript:\",\"targets\":\"function ucal ( u , n ) { if ( n == 0 ) return 1 ; var temp = u ; for ( var i = 1 ; i <= n \\/ 2 ; i ++ ) temp = temp * ( u - i ) ; for ( var i = 1 ; i < n \\/ 2 ; i ++ ) temp = temp * ( u + i ) ; return temp ; } function fact ( n ) { var f = 1 ; for ( var i = 2 ; i <= n ; i ++ ) f *= i ; return f ; } var n = 6 ; var x = [ 25 , 26 , 27 , 28 , 29 , 30 ] ; var y = Array ( n ) . fill ( 0.0 ) . map ( x => Array ( n ) . fill ( 0.0 ) ) ; ; y [ 0 ] [ 0 ] = 4.000 ; y [ 1 ] [ 0 ] = 3.846 ; y [ 2 ] [ 0 ] = 3.704 ; y [ 3 ] [ 0 ] = 3.571 ; y [ 4 ] [ 0 ] = 3.448 ; y [ 5 ] [ 0 ] = 3.333 ; for ( var i = 1 ; i < n ; i ++ ) for ( var j = 0 ; j < n - i ; j ++ ) y [ j ] [ i ] = y [ j + 1 ] [ i - 1 ] - y [ j ] [ i - 1 ] ; for ( var i = 0 ; i < n ; i ++ ) { for ( var j = 0 ; j < n - i ; j ++ ) document . write ( y [ i ] [ j ] . toFixed ( 6 ) + \\\" \\\" ) ; document . write ( ' ' ) ; } var value = 27.4 ; var sum = ( y [ 2 ] [ 0 ] + y [ 3 ] [ 0 ] ) \\/ 2 ; var k ; if ( ( n % 2 ) > 0 ) k = n \\/ 2 ; else k = n \\/ 2 - 1 ; var u = ( value - x [ k ] ) \\/ ( x [ 1 ] - x [ 0 ] ) ; for ( var i = 1 ; i < n ; i ++ ) { if ( ( i % 2 ) > 0 ) sum = sum + ( ( u - 0.5 ) * ucal ( u , i - 1 ) * y [ k ] [ i ] ) \\/ fact ( i ) ; else sum = sum + ( ucal ( u , i ) * ( y [ k ] [ i ] + y [ -- k ] [ i ] ) \\/ ( fact ( i ) * 2 ) ) ; } document . write ( \\\" \\\" + value . toFixed ( 6 ) + \\\" \\\" + sum . toFixed ( 6 ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Choose an integer K such that maximum of the xor values of K with all Array elements is minimized | C # implementation to find minimum possible value of the maximum xor in an array by choosing some integer ; Function to calculate minimum possible value of the maximum XOR in an array ; Base case ; Divide elements into two sections ; Traverse all elements of current section and divide in two groups ; Check if one of the sections is empty ; Explore both the possibilities using recursion ; Function to calculate minimum XOR value ; Start recursion from the most significant pos position ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; using System . Collections . Generic ; class GFG { static int calculate ( List < int > section , int pos ) { if ( pos < 0 ) return 0 ; List < int > on_section = new List < int > ( ) , off_section = new List < int > ( ) ; foreach ( int el in section ) { if ( ( ( el >> pos ) & 1 ) == 0 ) off_section . Add ( el ) ; else on_section . Add ( el ) ; } if ( off_section . Count == 0 ) return calculate ( on_section , pos - 1 ) ; if ( on_section . Count == 0 ) return calculate ( off_section , pos - 1 ) ; return Math . Min ( calculate ( off_section , pos - 1 ) , calculate ( on_section , pos - 1 ) ) + ( 1 << pos ) ; } static int minXorValue ( int [ ] a , int n ) { List < int > section = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) section . Add ( a [ i ] ) ; return calculate ( section , 30 ) ; } public static void Main ( String [ ] args ) { int N = 4 ; int [ ] A = { 3 , 2 , 5 , 6 } ; Console . Write ( minXorValue ( A , N ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Check if given number contains only “ 01 ” and “ 10 ” as substring in its binary representation | javascript Program to implement the above approach ; Function to generate all numbers having \\\"01\\\" and \\\"10\\\" as a substring ; Insert 2 and 5 ; Iterate till x is 10 ^ 15 ; Multiply x by 2 ; Update x as x * 2 + 1 ; Function to check if binary representation of N contains only \\\"01\\\" and \\\"10\\\" as substring ; Function Call to generate all such numbers ; Check if a number N exists in Ans or not ; If the number exists ; Driver Code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"var N = 200000 ; var Ans = Array . from ( { length : N } , ( _ , i ) => 0 ) ; var index = 0 ; function populateNumber ( ) { Ans [ index ++ ] = ( 2 ) ; Ans [ index ++ ] = ( 5 ) ; var x = 5 ; var inf = 1000000000001 ; while ( x < inf ) { x *= 2 ; Ans [ index ++ ] = ( x ) ; x = x * 2 + 1 ; Ans [ index ++ ] = ( x ) ; } } function checkString ( N ) { populateNumber ( ) ; for ( i = 0 ; i < index ; i ++ ) { if ( Ans [ i ] == N ) { document . write ( \\\" \\\" ) ; return ; } } document . write ( \\\" \\\" ) ; } N = 5 ; checkString ( N ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Maximum number of 2 x2 squares that can be fit inside a right isosceles triangle | C ++ program to count number of 2 x 2 squares in a right isosceles triangle ; removing the extra part we would always need ; Since each square has base of length of 2 ; Driver code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int numberOfSquares ( int base ) { base = ( base - 2 ) ; base = floor ( base \\/ 2 ) ; return base * ( base + 1 ) \\/ 2 ; } int main ( ) { int base = 8 ; cout << numberOfSquares ( base ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Dynamic Programming | A Dynamic Programming solution for subset sum problem ; Returns true if there is a subset of set [ ] with sum equal to given sum ; The value of subset [ i ] [ j ] will be true if there is a subset of set [ 0. . j - 1 ] with sum equal to i ; If sum is 0 , then answer is true ; If sum is not 0 and set is empty , then answer is false ; Fill the subset table in bottom up manner ; uncomment this code to print table ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"class GFG { static boolean isSubsetSum ( int set [ ] , int n , int sum ) { boolean subset [ ] [ ] = new boolean [ sum + 1 ] [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) subset [ 0 ] [ i ] = true ; for ( int i = 1 ; i <= sum ; i ++ ) subset [ i ] [ 0 ] = false ; for ( int i = 1 ; i <= sum ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { subset [ i ] [ j ] = subset [ i ] [ j - 1 ] ; if ( i >= set [ j - 1 ] ) subset [ i ] [ j ] = subset [ i ] [ j ] || subset [ i - set [ j - 1 ] ] [ j - 1 ] ; } } for ( int i = 0 ; i <= sum ; i ++ ) { for ( int j = 0 ; j <= n ; j ++ ) System . out . println ( subset [ i ] [ j ] ) ; } return subset [ sum ] [ n ] ; } public static void main ( String args [ ] ) { int set [ ] = { 3 , 34 , 4 , 12 , 5 , 2 } ; int sum = 9 ; int n = set . length ; if ( isSubsetSum ( set , n , sum ) == true ) System . out . println ( \\\" Found ▁ a ▁ subset \\\" + \\\" ▁ with ▁ given ▁ sum \\\" ) ; else System . out . println ( \\\" No ▁ subset ▁ with \\\" + \\\" ▁ given ▁ sum \\\" ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Count of Binary Digit numbers smaller than N | C # program to count all binary digit numbers smaller than N ; method returns count of binary digit numbers smaller than N ; queue to store all intermediate binary digit numbers ; binary digits start with 1 ; loop until we have element in queue ; push next binary digit numbers only if current popped element is N ; uncomment below line to print actual number in sorted order ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; using System . Collections . Generic ; class GFG { static int countOfBinaryNumberLessThanN ( int N ) { Queue < int > q = new Queue < int > ( ) ; q . Enqueue ( 1 ) ; int cnt = 0 ; int t ; while ( q . Count > 0 ) { t = q . Peek ( ) ; q . Dequeue ( ) ; if ( t <= N ) { cnt ++ ; q . Enqueue ( t * 10 ) ; q . Enqueue ( t * 10 + 1 ) ; } } return cnt ; } static void Main ( ) { int N = 200 ; Console . WriteLine ( countOfBinaryNumberLessThanN ( N ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Longest subarray not having more than K distinct elements | function to print the longest sub - array ; mark the element visited ; if its visited first time , then increase the counter of distinct elements by 1 ; When the counter of distinct elements increases from k , then reduce it to k ; from the left , reduce the number of time of visit ; if the reduced visited time element is not present in further segment then decrease the count of distinct elements ; increase the subsegment mark ; check length of longest sub - segment when greater then previous best then change it ; print the longest sub - segment ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"import collections\\ndef longest ( a , n , k ) :\\n\\tfreq = collections . defaultdict ( int )\\n\\tstart = 0\\n\\tend = 0\\n\\tnow = 0\\n\\tl = 0\\n\\tfor i in range ( n ) :\\n\\t\\tfreq [ a [ i ] ] += 1\\n\\t\\tif ( freq [ a [ i ] ] == 1 ) :\\n\\t\\t\\tnow += 1\\n\\t\\twhile ( now > k ) :\\n\\t\\t\\tfreq [ a [ l ] ] -= 1\\n\\t\\t\\tif ( freq [ a [ l ] ] == 0 ) :\\n\\t\\t\\t\\tnow -= 1\\n\\t\\t\\tl += 1\\n\\t\\tif ( i - l + 1 >= end - start + 1 ) :\\n\\t\\t\\tend = i\\n\\t\\t\\tstart = l\\n\\tfor i in range ( start , end + 1 ) :\\n\\t\\tprint ( a [ i ] , end = \\\" ▁ \\\" )\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\ta = [ 6 , 5 , 1 , 2 , 3 , 2 , 1 , 4 , 5 ]\\n\\tn = len ( a )\\n\\tk = 3\\n\\tlongest ( a , n , k )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Subtract 1 without arithmetic operators | C code to subtract one from a given number ; Flip all the set bits until we find a 1 ; flip the rightmost 1 bit ; Driver program to test above functions\\\"\\nSolution in C:\",\"targets\":\"#include \\nint subtractOne ( int x ) { int m = 1 ; while ( ! ( x & m ) ) { x = x ^ m ; m <<= 1 ; } x = x ^ m ; return x ; } int main ( ) { printf ( \\\" % d \\\" , subtractOne ( 13 ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Given an n x n square matrix , find sum of all sub | size k x k Size of given matrix ; function to find sum of all sub - squares of size k x k in a given square matrix of size n x n ; k must be smaller than or equal to n ; row number of first cell in current sub - square of size k x k ; column of first cell in current sub - square of size k x k ; Calculate and print sum of current sub - square ; Line separator for sub - squares starting with next row ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php $ n = 5 ; function printSumSimple ( $ mat , $ k ) { global $ n ; if ( $ k > $ n ) return ; for ( $ i = 0 ; $ i < $ n - $ k + 1 ; $ i ++ ) { for ( $ j = 0 ; $ j < $ n - $ k + 1 ; $ j ++ ) { $ sum = 0 ; for ( $ p = $ i ; $ p < $ k + $ i ; $ p ++ ) for ( $ q = $ j ; $ q < $ k + $ j ; $ q ++ ) $ sum += $ mat [ $ p ] [ $ q ] ; echo $ sum , \\\" \\\" ; } echo \\\" \\n \\\" ; } } $ mat = array ( array ( 1 , 1 , 1 , 1 , 1 ) , array ( 2 , 2 , 2 , 2 , 2 , ) , array ( 3 , 3 , 3 , 3 , 3 , ) , array ( 4 , 4 , 4 , 4 , 4 , ) , array ( 5 , 5 , 5 , 5 , 5 ) ) ; $ k = 3 ; printSumSimple ( $ mat , $ k ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Different substrings in a string that start and end with given strings | function to return number of different sub - strings ; initially our answer is zero . ; find the length of given strings ; currently make array and initially put zero . ; find occurrence of \\\" a \\\" and \\\" b \\\" in string \\\" s \\\" ; We use a hash to make sure that same substring is not counted twice . ; go through all the positions to find occurrence of \\\" a \\\" first . ; if we found occurrence of \\\" a \\\" . ; then go through all the positions to find occurrence of \\\" b \\\" . ; if we do found \\\" b \\\" at index j then add it to already existed substring . ; if we found occurrence of \\\" b \\\" . ; now add string \\\" b \\\" to already existed substring . ; If current substring is not included already . ; put any non negative integer to make this string as already existed . ; make substring null . ; return answer . ; Driver Code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function numberOfDifferentSubstrings ( s , a , b ) { let ans = 0 ; let ls = s . length ; let x = new Array ( ls ) ; let y = new Array ( ls ) ; for ( let i = 0 ; i < ls ; i ++ ) { x [ i ] = 0 ; y [ i ] = 0 ; } for ( let i = 0 ; i < ls ; i ++ ) { if ( s [ i ] == a ) x [ i ] = 1 ; if ( s [ i ] == b ) y [ i ] = 1 ; } let hash = new Set ( ) ; let curr_substr = \\\" \\\" ; for ( let i = 0 ; i < ls ; i ++ ) { if ( x [ i ] != 0 ) { for ( let j = i ; j < ls ; j ++ ) { if ( y [ j ] == 0 ) curr_substr += s [ i ] ; if ( y [ j ] != 0 ) { curr_substr += s [ j ] ; if ( ! hash . has ( curr_substr ) ) ans ++ ; hash . add ( curr_substr ) ; } } curr_substr = \\\" \\\" ; } } return ans ; } let s = \\\" \\\" ; let begin = ' ' ; let end = ' ' ; document . write ( numberOfDifferentSubstrings ( s , begin , end ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Encrypt a string by repeating i | Function to return the encrypted string ; Number of times the current character will be repeated ; Repeat the current character in the encrypted string ; Driver code\\\"\\nSolution in php:\",\"targets\":\"< ? php function encryptString ( $ str , $ n ) { $ i = 0 ; $ cnt = 0 ; $ encryptedStr = \\\" \\\" ; while ( $ i < $ n ) { $ cnt = $ i + 1 ; while ( $ cnt -- ) $ encryptedStr . = $ str [ $ i ] ; $ i ++ ; } return $ encryptedStr ; } $ str = \\\" geeks \\\" ; $ n = strlen ( $ str ) ; echo encryptString ( $ str , $ n ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Program for N | Java program to find nth term of Arithmetic progression ; using formula to find the Nth term t ( n ) = a ( 1 ) + ( n - 1 ) * d ; Driver code ; starting number ; Common difference ; N th term to be find ; Display the output\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . io . * ; import java . lang . * ; class GFG { public static int Nth_of_AP ( int a , int d , int N ) { return ( a + ( N - 1 ) * d ) ; } public static void main ( String [ ] args ) { int a = 2 ; int d = 1 ; int N = 5 ; System . out . print ( \\\" The ▁ \\\" + N + \\\" th ▁ term ▁ of ▁ the ▁ series ▁ is ▁ : ▁ \\\" + Nth_of_AP ( a , d , N ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Maximum sum such that no two elements are adjacent | ; Function to return max sum such that no two elements are adjacent ; current max excluding i ; current max including i ; return max of incl and excl ; Driver program to test above function\\\"\\nSolution in C:\",\"targets\":\"#include \\nint FindMaxSum ( int arr [ ] , int n ) { int incl = arr [ 0 ] ; int excl = 0 ; int excl_new ; int i ; for ( i = 1 ; i < n ; i ++ ) { excl_new = ( incl > excl ) ? incl : excl ; incl = excl + arr [ i ] ; excl = excl_new ; } return ( ( incl > excl ) ? incl : excl ) ; } int main ( ) { int arr [ ] = { 5 , 5 , 10 , 100 , 10 , 5 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; printf ( \\\" % d ▁ n \\\" , FindMaxSum ( arr , n ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Find the longest subsequence of an array having LCM at most K | Java implementation of the approach ; Function to find the longest subsequence having LCM less than or equal to K ; Map to store unique elements and their frequencies ; Update the frequencies ; Array to store the count of numbers whom 1 <= X <= K is a multiple of ; Check every unique element ; Find all its multiples <= K ; Store its frequency ; Obtain the number having maximum count ; Condition to check if answer doesn 't exist ; Print the answer ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"import java . util . * ; class GFG { static void findSubsequence ( int [ ] arr , int n , int k ) { HashMap < Integer , Integer > M = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; ++ i ) { if ( M . containsKey ( arr [ i ] ) ) M . put ( arr [ i ] , M . get ( arr [ i ] ) + 1 ) ; else M . put ( arr [ i ] , 1 ) ; } int [ ] numCount = new int [ k + 1 ] ; for ( int i = 0 ; i <= k ; ++ i ) numCount [ i ] = 0 ; Iterator < HashMap . Entry < Integer , Integer > > itr = M . entrySet ( ) . iterator ( ) ; while ( itr . hasNext ( ) ) { HashMap . Entry < Integer , Integer > entry = itr . next ( ) ; if ( entry . getKey ( ) <= k ) { for ( int i = 1 ; ; ++ i ) { if ( entry . getKey ( ) * i > k ) break ; numCount [ entry . getKey ( ) * i ] += entry . getValue ( ) ; } } else break ; } int lcm = 0 , length = 0 ; for ( int i = 1 ; i <= k ; ++ i ) { if ( numCount [ i ] > length ) { length = numCount [ i ] ; lcm = i ; } } if ( lcm == 0 ) System . out . println ( - 1 ) ; else { System . out . println ( \\\" LCM ▁ = ▁ \\\" + lcm + \\\" ▁ Length ▁ = ▁ \\\" + length ) ; System . out . print ( \\\" Indexes ▁ = ▁ \\\" ) ; for ( int i = 0 ; i < n ; ++ i ) if ( lcm % arr [ i ] == 0 ) System . out . print ( i + \\\" ▁ \\\" ) ; } } public static void main ( String [ ] args ) { int k = 14 ; int arr [ ] = { 2 , 3 , 4 , 5 } ; int n = arr . length ; findSubsequence ( arr , n , k ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Digit | function to produce and print Digit Product Sequence ; Array which store sequence ; Temporary variable to store product ; Initialize first element of the array with 1 ; Run a loop from 1 to N . Check if previous number is single digit or not . If yes then product = 1 else take modulus . Then again check if previous number is single digit or not if yes then store previous number , else store its first value Then for every i store value in the array . ; Print sequence ; Value of N ; Calling function\\\"\\nSolution in php:\",\"targets\":\"< ? php function digit_product_Sum ( $ N ) { $ a = array_fill ( 0 , $ N , 0 ) ; $ product = 1 ; $ a [ 0 ] = 1 ; for ( $ i = 1 ; $ i <= $ N ; $ i ++ ) { $ product = ( int ) ( $ a [ $ i - 1 ] \\/ 10 ) ; if ( $ product == 0 ) $ product = 1 ; else $ product = $ a [ $ i - 1 ] % 10 ; $ val = ( int ) ( $ a [ $ i - 1 ] \\/ 10 ) ; if ( $ val == 0 ) $ val = $ a [ $ i - 1 ] ; $ a [ $ i ] = $ a [ $ i - 1 ] + ( $ val * $ product ) ; } for ( $ i = 0 ; $ i < $ N ; $ i ++ ) echo $ a [ $ i ] . \\\" ▁ \\\" ; } $ N = 10 ; digit_product_Sum ( $ N ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Move all zeroes to end of array | Set | C # implementation to move all zeroes at the end of array ; function to move all zeroes at the end of array ; Count of non - zero elements ; Traverse the array . If arr [ i ] is non - zero , then swap the element at index ' count ' with the element at index ' i ' ; function to print the array elements ; Driver program to test above\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static void moveZerosToEnd ( int [ ] arr , int n ) { int count = 0 ; int temp ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( arr [ i ] != 0 ) ) { temp = arr [ count ] ; arr [ count ] = arr [ i ] ; arr [ i ] = temp ; count = count + 1 ; } } } static void printArray ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + \\\" ▁ \\\" ) ; } public static void Main ( ) { int [ ] arr = { 0 , 1 , 9 , 8 , 4 , 0 , 0 , 2 , 7 , 0 , 6 , 0 , 9 } ; int n = arr . Length ; Console . Write ( \\\" Original ▁ array : ▁ \\\" ) ; printArray ( arr , n ) ; moveZerosToEnd ( arr , n ) ; Console . Write ( \\\" \\n Modified ▁ array : ▁ \\\" ) ; printArray ( arr , n ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Sum of divisors of factorial of a number | C program to find sum of proper divisor of factorial of a number ; function to calculate factorial ; function to calculate sum of divisor ; Returns sum of divisors of n ! ; driver program\\\"\\nSolution in C:\",\"targets\":\"#include \\nint fact ( int n ) { if ( n == 0 ) return 1 ; return n * fact ( n - 1 ) ; } int div ( int x ) { int ans = 0 ; for ( int i = 1 ; i <= x ; i ++ ) if ( x % i == 0 ) ans += i ; return ans ; } int sumFactDiv ( int n ) { return div ( fact ( n ) ) ; } int main ( ) { int n = 4 ; printf ( \\\" % d \\\" , sumFactDiv ( n ) ) ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Count of numbers upto M with GCD equals to K when paired with M | Function to calculate GCD using euler totient function ; Finding the prime factors of limit to calculate it 's euler totient function ; Calculating the euler totient function of ( m \\/ k ) ; Function print the count of numbers whose GCD with M equals to K ; GCD of m with any integer cannot be equal to k ; 0 and m itself will be the only valid integers ; Finding the number upto which coefficient of k can come ; Driver Code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function EulerTotientFunction ( limit ) { let copy = limit ; let primes = [ ] ; for ( let i = 2 ; i * i <= limit ; i ++ ) { if ( limit % i == 0 ) { while ( limit % i == 0 ) { limit \\/= i ; } primes . push ( i ) ; } } if ( limit >= 2 ) { primes . push ( limit ) ; } let ans = copy ; for ( let it in primes ) { ans = ( ans \\/ primes [ it ] ) * ( primes [ it ] - 1 ) ; } return ans ; } function CountGCD ( m , k ) { if ( m % k != 0 ) { document . write ( 0 + \\\" \\\" ) ; return ; } if ( m == k ) { document . write ( 2 + \\\" \\\" ) ; return ; } let limit = Math . floor ( m \\/ k ) ; let ans = EulerTotientFunction ( limit ) ; document . write ( ans + \\\" \\\" ) ; } let M = 9 ; let K = 1 ; CountGCD ( M , K ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Find the last player to be able to flip a character in a Binary String | Python3 program for the above approach ; Function to check if player A wins the game or not ; Stores size of the groups of 0 s ; Stores size of the group of 0 s ; Traverse the array ; Increment c by 1 if a [ i ] is 0 ; Otherwise , push the size in array and reset c to 0 ; If there is no substring of odd length consisting only of 0 s ; If there is only 1 substring of odd length consisting only of 0 s ; Otherwise ; Stores the size of the largest and second largest substrings of 0 s ; Traverse the array v [ ] ; If current element is greater than first , then update both first and second ; If arr [ i ] is in between first and second , then update second ; If the condition is satisfied ; Driver code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"import sys\\ndef findWinner ( a , n ) :\\n\\tv = [ ]\\n\\tc = 0\\n\\tfor i in range ( 0 , n ) :\\n\\t\\tif ( a [ i ] == '0' ) :\\n\\t\\t\\tc += 1\\n\\t\\telse :\\n\\t\\t\\tif ( c != 0 ) :\\n\\t\\t\\t\\tv . append ( c )\\n\\t\\t\\tc = 0\\n\\tif ( c != 0 ) :\\n\\t\\tv . append ( c )\\n\\tif ( len ( v ) == 0 ) :\\n\\t\\tprint ( \\\" Player ▁ B \\\" , end = \\\" \\\" )\\n\\t\\treturn\\n\\tif ( len ( v ) == 1 ) :\\n\\t\\tif ( ( v [ 0 ] & 1 ) != 0 ) :\\n\\t\\t\\tprint ( \\\" Player ▁ A \\\" , end = \\\" \\\" )\\n\\t\\telse :\\n\\t\\t\\tprint ( \\\" Player ▁ B \\\" , end = \\\" \\\" )\\n\\t\\treturn\\n\\tfirst = sys . minsize\\n\\tsecond = sys . minsize\\n\\tfor i in range ( len ( v ) ) :\\n\\t\\tif ( a [ i ] > first ) :\\n\\t\\t\\tsecond = first\\n\\t\\t\\tfirst = a [ i ]\\n\\t\\telif ( a [ i ] > second and a [ i ] != first ) :\\n\\t\\t\\tsecond = a [ i ]\\n\\tif ( ( ( first & 1 ) != 0 ) and ( first + 1 ) \\/\\/ 2 > second ) :\\n\\t\\tprint ( \\\" Player ▁ A \\\" , end = \\\" \\\" )\\n\\telse :\\n\\t\\tprint ( \\\" Player ▁ B \\\" , end = \\\" \\\" )\\nS = \\\"1100011\\\"\\nN = len ( S )\\nfindWinner ( S , N )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Area of triangle formed by the axes of co | C ++ program area of triangle formed by the axes of co - ordinates and a given straight line ; Function to find area ; Driver code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; double area ( double a , double b , double c ) { double d = fabs ( ( c * c ) \\/ ( 2 * a * b ) ) ; return d ; } int main ( ) { double a = -2 , b = 4 , c = 3 ; cout << area ( a , b , c ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Trinomial Triangle | Function to find the trinomial triangle value . ; base case ; base case ; recursive step . ; Function to print Trinomial Triangle of height n . ; printing n rows . ; printing first half of triangle ; printing second half of triangle . ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function TrinomialValue ( $ n , $ k ) { if ( $ n == 0 && $ k == 0 ) return 1 ; if ( $ k < - $ n $ k > $ n ) return 0 ; return TrinomialValue ( $ n - 1 , $ k - 1 ) + TrinomialValue ( $ n - 1 , $ k ) + TrinomialValue ( $ n - 1 , $ k + 1 ) ; } function printTrinomial ( $ n ) { for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { for ( $ j = - $ i ; $ j <= 0 ; $ j ++ ) echo TrinomialValue ( $ i , $ j ) , \\\" ▁ \\\" ; for ( $ j = 1 ; $ j <= $ i ; $ j ++ ) echo TrinomialValue ( $ i , $ j ) , \\\" ▁ \\\" ; echo \\\" \\n \\\" ; } } $ n = 4 ; printTrinomial ( $ n ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Program to find all Factors of a Number using recursion | Java program to find all the factors of a number using recursion ; Recursive function to print factors of a number ; Checking if the number is less than N ; Calling the function recursively for the next number ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"class GFG { static void factors ( int n , int i ) { if ( i <= n ) { if ( n % i == 0 ) { System . out . print ( i + \\\" ▁ \\\" ) ; } factors ( n , i + 1 ) ; } } public static void main ( String args [ ] ) { int N = 16 ; factors ( N , 1 ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Change a Binary Tree so that every node stores sum of all nodes in left subtree | C program to store sum of nodes in left subtree in every node ; A tree node ; Function to modify a Binary Tree so that every node stores sum of values in its left child including its own value ; Base cases ; Update left and right subtrees ; Add leftsum to current node ; Return sum of values under root ; Utility function to do inorder traversal ; Utility function to create a new node ; Driver program ; Let us construct below tree 1 \\/ \\\\ 2 3 \\/ \\\\ \\\\ 4 5 6\\\"\\nSolution in C:\",\"targets\":\"#include \\nusing namespace std ; struct node { int data ; struct node * left , * right ; } ; int updatetree ( node * root ) { if ( ! root ) return 0 ; if ( root -> left == NULL && root -> right == NULL ) return root -> data ; int leftsum = updatetree ( root -> left ) ; int rightsum = updatetree ( root -> right ) ; root -> data += leftsum ; return root -> data + rightsum ; } void inorder ( struct node * node ) { if ( node == NULL ) return ; inorder ( node -> left ) ; printf ( \\\" % d ▁ \\\" , node -> data ) ; inorder ( node -> right ) ; } struct node * newNode ( int data ) { struct node * node = ( struct node * ) malloc ( sizeof ( struct node ) ) ; node -> data = data ; node -> left = NULL ; node -> right = NULL ; return ( node ) ; } int main ( ) { struct node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> left -> left = newNode ( 4 ) ; root -> left -> right = newNode ( 5 ) ; root -> right -> right = newNode ( 6 ) ; updatetree ( root ) ; cout << \\\" Inorder ▁ traversal ▁ of ▁ the ▁ modified ▁ tree ▁ is ▁ \\n \\\" ; inorder ( root ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Product of all sorted subsets of size K using elements whose index divide K completely | Java implementation of the above approach ; Iterative Function to calculate ( x ^ y ) % p in O ( log y ) ; If y is odd , multiply x with result ; y must be even now ; Iterative Function to calculate ( nCr ) % p and save in f [ n ] [ r ] ; If j > i then C ( i , j ) = 0 ; If iis equal to j then C ( i , j ) = 1 ; Function calculate the Final answer ; Initialize ans ; x is count of occurence of arr [ i ] in different set such that index of arr [ i ] in those sets divides K completely . ; Finding the count of arr [ i ] by placing it at index which divides K completely ; By Fermat 's theorem ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"import java . util . * ; class GFG { static int p = 1000000007 ; static int power ( int x , int y , int p ) { int res = 1 ; x = x % p ; while ( y > 0 ) { if ( y % 2 == 1 ) res = ( res * x ) % p ; y = y >> 1 ; x = ( x * x ) % p ; } return res ; } static void nCr ( int n , int p , int f [ ] [ ] , int m ) { for ( int i = 0 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= m ; j ++ ) { if ( j > i ) { f [ i ] [ j ] = 0 ; } else if ( j == 0 j == i ) { f [ i ] [ j ] = 1 ; } else { f [ i ] [ j ] = ( f [ i - 1 ] [ j ] + f [ i - 1 ] [ j - 1 ] ) % p ; } } } } static void ProductOfSubsets ( int arr [ ] , int n , int m ) { int [ ] [ ] f = new int [ n + 1 ] [ 100 ] ; nCr ( n , p - 1 , f , m ) ; Arrays . sort ( arr ) ; long ans = 1 ; for ( int i = 0 ; i < n ; i ++ ) { int x = 0 ; for ( int j = 1 ; j <= m ; j ++ ) { if ( m % j == 0 ) { x = ( x + ( f [ n - i - 1 ] [ m - j ] * f [ i ] [ j - 1 ] ) % ( p - 1 ) ) % ( p - 1 ) ; } } ans = ( ( ans * power ( arr [ i ] , x , p ) ) % p ) ; } System . out . print ( ans + \\\"\\n\\\"); } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 5 , 7 , 9 , 3 } ; int K = 4 ; int N = arr . length ; ProductOfSubsets ( arr , N , K ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Find most significant set bit of a number | Python program to find MSB number for given n . ; Suppose n is 273 ( binary is 100010001 ) . It does following 100010001 | 010001000 = 110011001 ; This makes sure 4 bits ( From MSB and including MSB ) are set . It does following 110011001 | 001100110 = 111111111 ; Increment n by 1 so that there is only one set bit which is just before original MSB . n now becomes 1000000000 ; Return original MSB after shifting . n now becomes 100000000 ; Driver code\\\"\\nSolution in Python:\",\"targets\":\"def setBitNumber ( n ) :\\n\\tn |= n >> 1\\n\\tn |= n >> 2\\n\\tn |= n >> 4\\n\\tn |= n >> 8\\n\\tn |= n >> 16\\n\\tn = n + 1\\n\\treturn ( n >> 1 )\\nn = 273\\nprint ( setBitNumber ( n ) )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Find the two numbers with odd occurrences in an unsorted array | Program to find the two odd occurring elements ; Prints two numbers that occur odd number of times . The function assumes that the array size is at least 2 and there are exactly two numbers occurring odd number of times . ; Will hold XOR of two odd occurring elements ; Will have only single set bit of xor2 ; Get the xor of all elements in arr [ ] . The xor will basically be xor of two odd occurring elements ; Get one set bit in the xor2 . We get rightmost set bit in the following line as it is easy to get ; Now divide elements in two sets : 1 ) The elements having the corresponding bit as 1. 2 ) The elements having the corresponding bit as 0. ; XOR of first set is finally going to hold one odd occurring number x ; XOR of second set is finally going to hold the other odd occurring number y ; Driver program to test above function\\\"\\nSolution in C:\",\"targets\":\"#include \\nvoid printTwoOdd ( int arr [ ] , int size ) { int xor2 = arr [ 0 ] ; int set_bit_no ; int i ; int n = size - 2 ; int x = 0 , y = 0 ; for ( i = 1 ; i < size ; i ++ ) xor2 = xor2 ^ arr [ i ] ; set_bit_no = xor2 & ~ ( xor2 - 1 ) ; for ( i = 0 ; i < size ; i ++ ) { if ( arr [ i ] & set_bit_no ) x = x ^ arr [ i ] ; else y = y ^ arr [ i ] ; } printf ( \\\" The two ODD elements are % d & % d \\\" , x , y ) ; } int main ( ) { int arr [ ] = { 4 , 2 , 4 , 5 , 2 , 3 , 3 , 1 } ; int arr_size = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; printTwoOdd ( arr , arr_size ) ; getchar ( ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Given an array arr [ ] , find the maximum j | For a given array arr [ ] , returns the maximum j a i such that arr [ j ] > arr [ i ] ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function maxIndexDiff ( $ arr , $ n ) { $ maxDiff = -1 ; for ( $ i = 0 ; $ i < $ n ; ++ $ i ) { for ( $ j = $ n - 1 ; $ j > $ i ; -- $ j ) { if ( $ arr [ $ j ] > $ arr [ $ i ] && $ maxDiff < ( $ j - $ i ) ) $ maxDiff = $ j - $ i ; } } return $ maxDiff ; } $ arr = array ( 9 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 18 , 0 ) ; $ n = count ( $ arr ) ; $ maxDiff = maxIndexDiff ( $ arr , $ n ) ; echo $ maxDiff ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Count integers up to N which can be represented as sum of two or more consecutive numbers | Java program of the above approach ; Function to check if the number N can be expressed as sum of 2 or more consecutive numbers or not ; Function to count integers in the range [ 1 , N ] that can be expressed as sum of 2 or more consecutive numbers ; Stores the required count ; Driver Code\\\"\\nSolution in Java:\",\"targets\":\"import java . io . * ; class GFG { static int isPossible ( int N ) { return ( ( ( N & ( N - 1 ) ) & N ) ) ; } static void countElements ( int N ) { int count = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { if ( isPossible ( i ) != 0 ) count ++ ; } System . out . println ( count ) ; } public static void main ( String [ ] args ) { int N = 15 ; countElements ( N ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Count ways to obtain given sum by repeated throws of a dice | C ++ Program for the above approach ; Function to calculate the total number of ways to have sum N ; Base Case ; Return already stored result ; Recur for all 6 states ; Return the result ; Driver Code ; Given sum N ; Initialize the dp array ; Function Call\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int findWays ( int N , int dp [ ] ) { if ( N == 0 ) { return 1 ; } if ( dp [ N ] != -1 ) { return dp [ N ] ; } int cnt = 0 ; for ( int i = 1 ; i <= 6 ; i ++ ) { if ( N - i >= 0 ) { cnt = cnt + findWays ( N - i , dp ) ; } } return dp [ N ] = cnt ; } int main ( ) { int N = 4 ; int dp [ N + 1 ] ; memset ( dp , -1 , sizeof ( dp ) ) ; cout << findWays ( N , dp ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"Insertion Sort | C program for insertion sort ; Function to sort an array using insertion sort ; Move elements of arr [ 0. . i - 1 ] , that are greater than key , to one position ahead of their current position ; A utility function to print an array of size n ; Driver program to test insertion sort\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#include \\nvoid insertionSort ( int arr [ ] , int n ) { int i , key , j ; for ( i = 1 ; i < n ; i ++ ) { key = arr [ i ] ; j = i - 1 ; while ( j >= 0 && arr [ j ] > key ) { arr [ j + 1 ] = arr [ j ] ; j = j - 1 ; } arr [ j + 1 ] = key ; } } void printArray ( int arr [ ] , int n ) { int i ; for ( i = 0 ; i < n ; i ++ ) printf ( \\\" % d ▁ \\\" , arr [ i ] ) ; printf ( \\\" \\n \\\" ) ; } int main ( ) { int arr [ ] = { 12 , 11 , 13 , 5 , 6 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; insertionSort ( arr , n ) ; printArray ( arr , n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Program to print non square numbers | CPP program to print first n non - square numbers . ; Function to check perfect square ; function to print all non square number ; variable which stores the count ; not perfect square ; Driver code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; bool isPerfectSquare ( int n ) { if ( n < 0 ) return false ; int root = round ( sqrt ( n ) ) ) ; return n == root * root ; } void printnonsquare ( int n ) { int count = 0 ; for ( int i = 1 ; count < n ; ++ i ) { if ( ! isPerfectSquare ( i ) ) { cout << i << \\\" ▁ \\\" ; count ++ ; } } } int main ( ) { int n = 10 ; printnonsquare ( n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Sum of numbers from 1 to N which are divisible by 3 or 4 | C # program to find sum of numbers from 1 to N which are divisible by 3 or 4 ; Function to calculate the sum of numbers divisible by 3 or 4 ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int sum ( int N ) { int S1 , S2 , S3 ; S1 = ( ( N \\/ 3 ) ) * ( 2 * 3 + ( N \\/ 3 - 1 ) * 3 ) \\/ 2 ; S2 = ( ( N \\/ 4 ) ) * ( 2 * 4 + ( N \\/ 4 - 1 ) * 4 ) \\/ 2 ; S3 = ( ( N \\/ 12 ) ) * ( 2 * 12 + ( N \\/ 12 - 1 ) * 12 ) \\/ 2 ; return S1 + S2 - S3 ; } public static void Main ( ) { int N = 20 ; Console . WriteLine ( sum ( 12 ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"How to solve a Dynamic Programming Problem ? | Returns the number of arrangements to form ' n ' ; base case\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function solve ( n ) { if ( n < 0 ) return 0 ; if ( n == 0 ) return 1 ; return solve ( n - 1 ) + solve ( n - 3 ) + solve ( n - 5 ) ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"Subset Sum Problem in O ( sum ) space | Returns true if there exists a subset with given sum in arr [ ] ; The value of subset [ i % 2 ] [ j ] will be true if there exists a subset of sum j in arr [ 0 , 1 , ... . , i - 1 ] ; A subset with sum 0 is always possible ; If there exists no element no sum is possible ; Driver code\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#include \\nbool isSubsetSum ( int arr [ ] , int n , int sum ) { bool subset [ 2 ] [ sum + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= sum ; j ++ ) { if ( j == 0 ) subset [ i % 2 ] [ j ] = true ; else if ( i == 0 ) subset [ i % 2 ] [ j ] = false ; else if ( arr [ i - 1 ] <= j ) subset [ i % 2 ] [ j ] = subset [ ( i + 1 ) % 2 ] [ j - arr [ i - 1 ] ] || subset [ ( i + 1 ) % 2 ] [ j ] ; else subset [ i % 2 ] [ j ] = subset [ ( i + 1 ) % 2 ] [ j ] ; } } return subset [ n % 2 ] [ sum ] ; } int main ( ) { int arr [ ] = { 6 , 2 , 5 } ; int sum = 7 ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; if ( isSubsetSum ( arr , n , sum ) == true ) printf ( \\\" There ▁ exists ▁ a ▁ subset ▁ with ▁ given ▁ sum \\\" ) ; else printf ( \\\" No ▁ subset ▁ exists ▁ with ▁ given ▁ sum \\\" ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"N Queen Problem | Backtracking | Python3 program to solve N Queen Problem using backtracking ; ld is an array where its indices indicate row - col + N - 1 ( N - 1 ) is for shifting the difference to store negative indices ; rd is an array where its indices indicate row + col and used to check whether a queen can be placed on right diagonal or not ; column array where its indices indicates column and used to check whether a queen can be placed in that row or not ; A utility function to print solution ; A recursive utility function to solve N Queen problem ; base case : If all queens are placed then return True ; Consider this column and try placing this queen in all rows one by one ; A check if a queen can be placed on board [ row ] [ col ] . We just need to check ld [ row - col + n - 1 ] and rd [ row + coln ] where ld and rd are for left and right diagonal respectively ; Place this queen in board [ i ] [ col ] ; recur to place rest of the queens ; board [ i ] [ col ] = 0 BACKTRACK ; If the queen cannot be placed in any row in this colum col then return False ; This function solves the N Queen problem using Backtracking . It mainly uses solveNQUtil ( ) to solve the problem . It returns False if queens cannot be placed , otherwise , return True and prints placement of queens in the form of 1 s . Please note that there may be more than one solutions , this function prints one of the feasible solutions . ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"N = 4\\nld = [ 0 ] * 30\\nrd = [ 0 ] * 30\\ncl = [ 0 ] * 30\\ndef printSolution ( board ) :\\n\\tfor i in range ( N ) :\\n\\t\\tfor j in range ( N ) :\\n\\t\\t\\tprint ( board [ i ] [ j ] , end = \\\" ▁ \\\" )\\n\\t\\tprint ( )\\ndef solveNQUtil ( board , col ) :\\n\\tif ( col >= N ) :\\n\\t\\treturn True\\n\\tfor i in range ( N ) :\\n\\t\\tif ( ( ld [ i - col + N - 1 ] != 1 and rd [ i + col ] != 1 ) and cl [ i ] != 1 ) :\\n\\t\\t\\tboard [ i ] [ col ] = 1\\n\\t\\t\\tld [ i - col + N - 1 ] = rd [ i + col ] = cl [ i ] = 1\\n\\t\\t\\tif ( solveNQUtil ( board , col + 1 ) ) :\\n\\t\\t\\t\\treturn True\\n\\t\\t\\tld [ i - col + N - 1 ] = rd [ i + col ] = cl [ i ] = 0\\n\\treturn False\\ndef solveNQ ( ) :\\n\\tboard = [ [ 0 , 0 , 0 , 0 ] , [ 0 , 0 , 0 , 0 ] , [ 0 , 0 , 0 , 0 ] , [ 0 , 0 , 0 , 0 ] ]\\n\\tif ( solveNQUtil ( board , 0 ) == False ) :\\n\\t\\tprintf ( \\\" Solution ▁ does ▁ not ▁ exist \\\" )\\n\\t\\treturn False\\n\\tprintSolution ( board )\\n\\treturn True\\nsolveNQ ( )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"Partition problem | DP | A Dynamic Programming based C program to partition problem ; Returns true if arr [ ] can be partitioned in two subsets of equal sum , otherwise false ; Calculate sum of all elements ; initialize top row as true ; initialize leftmost column , except part [ 0 ] [ 0 ] , as 0 ; Fill the partition table in bottom up manner ; uncomment this part to print table ; Driver code ; Function call\\nHow can the above be solved in C?\",\"targets\":\"#include \\nbool findPartiion ( int arr [ ] , int n ) { int sum = 0 ; int i , j ; for ( i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; if ( sum % 2 != 0 ) return false ; bool part [ sum \\/ 2 + 1 ] [ n + 1 ] ; for ( i = 0 ; i <= n ; i ++ ) part [ 0 ] [ i ] = true ; for ( i = 1 ; i <= sum \\/ 2 ; i ++ ) part [ i ] [ 0 ] = false ; for ( i = 1 ; i <= sum \\/ 2 ; i ++ ) { for ( j = 1 ; j <= n ; j ++ ) { part [ i ] [ j ] = part [ i ] [ j - 1 ] ; if ( i >= arr [ j - 1 ] ) part [ i ] [ j ] = part [ i ] [ j ] || part [ i - arr [ j - 1 ] ] [ j - 1 ] ; } } return part [ sum \\/ 2 ] [ n ] ; } int main ( ) { int arr [ ] = { 3 , 1 , 1 , 2 , 2 , 1 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; if ( findPartiion ( arr , n ) == true ) printf ( \\\" Can ▁ be ▁ divided ▁ into ▁ two ▁ subsets ▁ of ▁ equal ▁ sum \\\" ) ; else printf ( \\\" Can ▁ not ▁ be ▁ divided ▁ into ▁ two ▁ subsets ▁ of ▁ \\\" \\\" equal ▁ sum \\\" ) ; getchar ( ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"Check for Majority Element in a sorted array | C Program to check for majority element in a sorted array ; If x is present in arr [ low ... high ] then returns the index of first occurrence of x , otherwise returns - 1 ; Check if arr [ mid ] is the first occurrence of x . arr [ mid ] is first occurrence if x is one of the following is true : ( i ) mid == 0 and arr [ mid ] = = x ( ii ) arr [ mid - 1 ] < x and arr [ mid ] == x ; This function returns true if the x is present more than n \\/ 2 times in arr [ ] of size n ; Find the index of first occurrence of x in arr [ ] ; If element is not present at all , return false ; check if the element is present more than n \\/ 2 times ; Driver program to check above functions\\nHow can the above be solved in C?\",\"targets\":\"# include \\n# include \\nint _binarySearch ( int arr [ ] , int low , int high , int x ) { if ( high >= low ) { int mid = ( low + high ) \\/ 2 ; if ( ( mid == 0 x > arr [ mid - 1 ] ) && ( arr [ mid ] == x ) ) return mid ; else if ( x > arr [ mid ] ) return _binarySearch ( arr , ( mid + 1 ) , high , x ) ; else return _binarySearch ( arr , low , ( mid - 1 ) , x ) ; } return -1 ; } bool isMajority ( int arr [ ] , int n , int x ) { int i = _binarySearch ( arr , 0 , n - 1 , x ) ; if ( i == -1 ) return false ; if ( ( ( i + n \\/ 2 ) <= ( n - 1 ) ) && arr [ i + n \\/ 2 ] == x ) return true ; else return false ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 3 , 3 , 3 , 10 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; int x = 3 ; if ( isMajority ( arr , n , x ) ) printf ( \\\" % d ▁ appears ▁ more ▁ than ▁ % d ▁ times ▁ in ▁ arr [ ] \\\" , x , n \\/ 2 ) ; else printf ( \\\" % d ▁ does ▁ not ▁ appear ▁ more ▁ than ▁ % d ▁ times ▁ in ▁ arr [ ] \\\" , x , n \\/ 2 ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Maximum length of subarray consisting of same type of element on both halves of sub | Java program for the above approach ; Function that finds the maximum length of the sub - array that contains equal element on both halves of sub - array ; To store continuous occurence of the element ; To store continuous forkward occurence ; To store continuous backward occurence ; To store the maximum length ; Find maximum length ; Print the result ; Driver Code ; Given array ; Size of the array ; Function call\\\"\\nSolution in Java:\",\"targets\":\"class GFG { static void maxLengthSubArray ( int A [ ] , int N ) { int forward [ ] = new int [ N ] ; int backward [ ] = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { if ( i == 0 A [ i ] != A [ i - 1 ] ) { forward [ i ] = 1 ; } else forward [ i ] = forward [ i - 1 ] + 1 ; } for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( i == N - 1 A [ i ] != A [ i + 1 ] ) { backward [ i ] = 1 ; } else backward [ i ] = backward [ i + 1 ] + 1 ; } int ans = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( A [ i ] != A [ i + 1 ] ) ans = Math . max ( ans , Math . min ( forward [ i ] , backward [ i + 1 ] ) * 2 ) ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 4 , 4 , 6 , 6 , 6 , 9 } ; int N = arr . length ; maxLengthSubArray ( arr , N ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Reverse words in a given string | C ++ program to reverse a string s = input ( )\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int main ( ) { string s [ ] = { \\\" i \\\" , \\\" like \\\" , \\\" this \\\" , \\\" program \\\" , \\\" very \\\" , \\\" much \\\" } ; string ans = \\\" \\\" ; for ( int i = 5 ; i >= 0 ; i -- ) { ans += s [ i ] + \\\" ▁ \\\" ; } cout << ( \\\" Reversed ▁ String : \\\" ) << endl ; cout << ( ans . substr ( 0 , ans . length ( ) - 1 ) ) << endl ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Calculate depth of a full Binary tree from Preorder | C ++ program to find height of full binary tree using preorder ; function to return max of left subtree height or right subtree height ; calc height of left subtree ( In preorder left subtree is processed before right ) ; calc height of right subtree ; Wrapper over findDepthRec ( ) ; Driver program\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int findDepthRec ( char tree [ ] , int n , int & index ) { if ( index >= n tree [ index ] == ' l ' ) return 0 ; index ++ ; int left = findDepthRec ( tree , n , index ) ; index ++ ; int right = findDepthRec ( tree , n , index ) ; return max ( left , right ) + 1 ; } int findDepth ( char tree [ ] , int n ) { int index = 0 ; findDepthRec ( tree , n , index ) ; } int main ( ) { char tree [ ] = \\\" nlnnlll \\\" ; int n = strlen ( tree ) ; cout << findDepth ( tree , n ) << endl ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Find the maximum length of the prefix | C ++ implementation of the approach ; Function to return the maximum length of the required prefix ; Array to store the frequency of each element of the array ; Iterating for all the elements ; Update the frequency of the current element i . e . v ; Sorted positive values from counts array ; If current prefix satisfies the given conditions ; Return the maximum length ; Driver code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int Maximum_Length ( vector < int > a ) { int counts [ 11 ] = { 0 } ; int ans = 0 ; for ( int index = 0 ; index < a . size ( ) ; index ++ ) { counts [ a [ index ] ] += 1 ; vector < int > k ; for ( auto i : counts ) if ( i != 0 ) k . push_back ( i ) ; sort ( k . begin ( ) , k . end ( ) ) ; if ( k . size ( ) == 1 || ( k [ 0 ] == k [ k . size ( ) - 2 ] && k . back ( ) - k [ k . size ( ) - 2 ] == 1 ) || ( k [ 0 ] == 1 and k [ 1 ] == k . back ( ) ) ) ans = index ; } return ans + 1 ; } int main ( ) { vector < int > a = { 1 , 1 , 1 , 2 , 2 , 2 } ; cout << ( Maximum_Length ( a ) ) ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Find maximum average subarray of k length | Returns beginning index of maximum average subarray of length k ; Check if ' k ' is valid ; Create and fill array to store cumulative sum . csum [ i ] stores sum of arr [ 0 ] to arr [ i ] ; Initialize max_sm as sum of first subarray ; Find sum of other subarrays and update max_sum if required . ; Return starting index ; Driver program\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def findMaxAverage ( arr , n , k ) :\\n\\tif k > n :\\n\\t\\treturn - 1\\n\\tcsum = [ 0 ] * n\\n\\tcsum [ 0 ] = arr [ 0 ]\\n\\tfor i in range ( 1 , n ) :\\n\\t\\tcsum [ i ] = csum [ i - 1 ] + arr [ i ] ;\\n\\tmax_sum = csum [ k - 1 ]\\n\\tmax_end = k - 1\\n\\tfor i in range ( k , n ) :\\n\\t\\tcurr_sum = csum [ i ] - csum [ i - k ]\\n\\t\\tif curr_sum > max_sum :\\n\\t\\t\\tmax_sum = curr_sum\\n\\t\\t\\tmax_end = i\\n\\treturn max_end - k + 1\\narr = [ 1 , 12 , - 5 , - 6 , 50 , 3 ]\\nk = 4\\nn = len ( arr )\\nprint ( \\\" The ▁ maximum ▁ average ▁ subarray ▁ of ▁ length \\\" , k , \\\" begins ▁ at ▁ index \\\" , findMaxAverage ( arr , n , k ) )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"k | C # program for above approach ; Function to find kth missing number ; If the total missing number count is equal to k we can iterate backwards for the first missing number and that will be the answer . ; To further optimize we check if the previous element ' s ▁ ▁ missing ▁ number ▁ count ▁ is ▁ equal ▁ ▁ to ▁ k . ▁ Eg : ▁ arr ▁ = ▁ [ 4,5,6,7,8 ] ▁ ▁ If ▁ you ▁ observe ▁ in ▁ the ▁ example ▁ array , ▁ ▁ the ▁ total ▁ count ▁ of ▁ missing ▁ numbers ▁ for ▁ all ▁ ▁ the ▁ indices ▁ are ▁ same , ▁ and ▁ we ▁ are ▁ ▁ aiming ▁ to ▁ narrow ▁ down ▁ the ▁ ▁ search ▁ window ▁ and ▁ achieve ▁ O ( logn ) ▁ ▁ time ▁ complexity ▁ which ▁ ▁ otherwise ▁ would ' ve been O ( n ) . ; Else we return arr [ mid ] - 1. ; Here we appropriately narrow down the search window . ; In case the upper limit is - ve it means the missing number set is 1 , 2 , . . , k and hence we directly return k . ; Else we find the residual count of numbers which we 'd then add to arr[u] and get the missing kth number. ; Return arr [ u ] + k ; Driver code ; Function Call\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int missingK ( int [ ] arr , int k ) { int n = arr . Length ; int l = 0 , u = n - 1 , mid ; while ( l <= u ) { mid = ( l + u ) \\/ 2 ; int numbers_less_than_mid = arr [ mid ] - ( mid + 1 ) ; if ( numbers_less_than_mid == k ) { if ( mid > 0 && ( arr [ mid - 1 ] - ( mid ) ) == k ) { u = mid - 1 ; continue ; } return arr [ mid ] - 1 ; } if ( numbers_less_than_mid < k ) { l = mid + 1 ; } else if ( k < numbers_less_than_mid ) { u = mid - 1 ; } } if ( u < 0 ) return k ; int less = arr [ u ] - ( u + 1 ) ; k -= less ; return arr [ u ] + k ; } static void Main ( ) { int [ ] arr = { 2 , 3 , 4 , 7 , 11 } ; int k = 5 ; Console . WriteLine ( \\\" Missing ▁ kth ▁ number ▁ = ▁ \\\" + missingK ( arr , k ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Check if given string is a substring of string formed by repeated concatenation of z to a | Java program for the above approach ; Function checks if a given string is valid or not and prints the output ; Boolean flag variable to mark if given string is valid ; Traverse the given string ; If adjacent character differ by 1 ; If character ' a ' is followed by 4 ; Else flip the flag and break from the loop ; Output according to flag variable ; Driver code ; Given string ; Function call\\\"\\nSolution in Java:\",\"targets\":\"class GFG { public static void checkInfinite ( String s ) { boolean flag = true ; int N = s . length ( ) ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( s . charAt ( i ) == ( char ) ( ( int ) ( s . charAt ( i + 1 ) ) + 1 ) ) { continue ; } else if ( s . charAt ( i ) == ' a ' && s . charAt ( i + 1 ) == ' z ' ) { continue ; } else { flag = false ; break ; } } if ( ! flag ) System . out . print ( \\\" NO \\\" ) ; else System . out . print ( \\\" YES \\\" ) ; } public static void main ( String [ ] args ) { String s = \\\" ecbaz \\\" ; checkInfinite ( s ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Average of a stream of numbers | Returns the new average after including x ; Prints average of a stream of numbers ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function getAvg ( $ prev_avg , $ x , $ n ) { return ( $ prev_avg * $ n + $ x ) \\/ ( $ n + 1 ) ; } function streamAvg ( $ arr , $ n ) { $ avg = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { $ avg = getAvg ( $ avg , $ arr [ $ i ] , $ i ) ; echo \\\" Average ▁ of ▁ \\\" , $ i + 1 , \\\" numbers ▁ is ▁ \\\" , $ avg , \\\" \\n \\\" ; } return ; } $ arr = array ( 10 , 20 , 30 , 40 , 50 , 60 ) ; $ n = sizeof ( $ arr ) ; streamAvg ( $ arr , $ n ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Longest Subsequence of a String containing only Consonants | Returns true if x is consonants . ; Function to check whether a character is consonants or not ; Function to find the longest subsequence which contain all consonants ; Driver code ; Function call\\\"\\nSolution in Javascript:\",\"targets\":\"function isConsonants ( x ) { x = x . toLowerCase ( ) ; return ! ( x === \\\" \\\" x === \\\" \\\" x === \\\" \\\" x === \\\" \\\" x === \\\" \\\" ) ; } function longestConsonantsSubsequence ( str ) { var answer = \\\" \\\" ; var n = str . length ; for ( var i = 0 ; i < n ; i ++ ) { if ( isConsonants ( str [ i ] ) ) { answer += str [ i ] ; } } return answer ; } var str = \\\" \\\" ; document . write ( longestConsonantsSubsequence ( str ) + \\\" \\\" ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Split a Binary String such that count of 0 s and 1 s in left and right substrings is maximum | Java program to implement the above approach ; Function to find the maximum sum of count of 0 s in the left subString and count of 1 s in the right subString by splitting the String ; Stores count of 1 s the in binary String ; Traverse the binary String ; If current character is '1' ; Update cntOne ; Stores count of 0 s ; Stores count of 1 s ; Stores maximum sum of count of 0 s and 1 s by splitting the String ; Traverse the binary String ; If current character is '0' ; Update zero ; If current character is '1' ; Update one ; Update res ; Driver Code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { static int maxSumbySplittingString ( String str , int N ) { int cntOne = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( str . charAt ( i ) == '1' ) { cntOne ++ ; } } int zero = 0 ; int one = 0 ; int res = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( str . charAt ( i ) == '0' ) { zero ++ ; } else { one ++ ; } res = Math . max ( res , zero + cntOne - one ) ; } return res ; } public static void main ( String [ ] args ) { String str = \\\"00111\\\" ; int N = str . length ( ) ; System . out . print ( maxSumbySplittingString ( str , N ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Remove minimum number of characters so that two strings become anagram | function to calculate minimum numbers of characters to be removed to make two strings anagram ; make hash array for both string and calculate frequency of each character ; count frequency of each character in first string ; count frequency of each character in second string ; traverse count arrays to find number of characters to be removed ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function remAnagram ( $ str1 , $ str2 ) { $ count1 = array ( 26 ) ; $ count2 = array ( 26 ) ; for ( $ i = 0 ; $ i < strlen ( $ str1 ) ; $ i ++ ) $ count1 [ $ str1 [ $ i ] - ' a ' ] ++ ; for ( $ i = 0 ; $ i < strlen ( $ str2 ) ; $ i ++ ) $ count2 [ $ str2 [ $ i ] - ' a ' ] ++ ; $ result = 0 ; for ( $ i = 0 ; $ i < 26 ; $ i ++ ) $ result += abs ( $ count1 [ $ i ] - $ count2 [ $ i ] ) ; return $ result ; } { $ str1 = \\\" bcadeh \\\" ; $ str2 = \\\" hea \\\" ; echo ( remAnagram ( $ str1 , $ str2 ) ) ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Count set bits in an integer | Lookup table ; Function to initialise the lookup table ; To initially generate the table algorithmically ; Function to return the count of set bits in n ; Initialise the lookup table\\\"\\nSolution in Javascript:\",\"targets\":\"var BitsSetTable256 = Array . from ( { length : 256 } , ( _ , i ) => 0 ) ; function initialize ( ) { BitsSetTable256 [ 0 ] = 0 ; for ( var i = 0 ; i < 256 ; i ++ ) { BitsSetTable256 [ i ] = ( i & 1 ) + BitsSetTable256 [ parseInt ( i \\/ 2 ) ] ; } } function countSetBits ( n ) { return ( BitsSetTable256 [ n & 0xff ] + BitsSetTable256 [ ( n >> 8 ) & 0xff ] + BitsSetTable256 [ ( n >> 16 ) & 0xff ] + BitsSetTable256 [ n >> 24 ] ) ; } initialize ( ) ; var n = 9 ; document . write ( countSetBits ( n ) ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Automorphic Number | Function to check Automorphic number ; Store the square ; Start Comparing digits ; Return false , if any digit of N doesn ' t ▁ ▁ match ▁ with ▁ its ▁ square ' s digits from last ; Reduce N and square ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function isAutomorphic ( $ N ) { $ sq = $ N * $ N ; while ( $ N > 0 ) { if ( $ N % 10 != $ sq % 10 ) return -1 ; $ N \\/= 10 ; $ sq \\/= 10 ; } return 1 ; } $ N = 5 ; $ geeks = isAutomorphic ( $ N ) ? \\\" Automorphic \\\" : \\\" Not ▁ Automorphic \\\" ; echo $ geeks ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Sum of even values and update queries on an array | Java implementation of the approach ; Function to print the result for every query ; If current element is even ; If element is even then remove it from sum ; If the value becomes even after updating ; Store sum for each query ; Print the result for every query ; Driver code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"class GFG { static void BalanceArray ( int [ ] A , int [ ] [ ] Q ) { int [ ] ANS = new int [ A . length ] ; int i , sum = 0 ; for ( i = 0 ; i < A . length ; i ++ ) if ( A [ i ] % 2 == 0 ) sum = sum + A [ i ] ; for ( i = 0 ; i < Q . length ; i ++ ) { int index = Q [ i ] [ 0 ] ; int value = Q [ i ] [ 1 ] ; if ( A [ index ] % 2 == 0 ) sum = sum - A [ index ] ; A [ index ] = A [ index ] + value ; if ( A [ index ] % 2 == 0 ) sum = sum + A [ index ] ; ANS [ i ] = sum ; } for ( i = 0 ; i < ANS . length ; i ++ ) System . out . print ( ANS [ i ] + \\\" ▁ \\\" ) ; } public static void main ( String [ ] args ) { int [ ] A = { 1 , 2 , 3 , 4 } ; int [ ] [ ] Q = { { 0 , 1 } , { 1 , - 3 } , { 0 , - 4 } , { 3 , 2 } } ; BalanceArray ( A , Q ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Ford | C ++ program for implementation of Ford Fulkerson algorithm ; Number of vertices in given graph ; Returns true if there is a path from source ' s ' to sink ' t ' in residual graph . Also fills parent [ ] to store the path ; Create a visited array and mark all vertices as not visited ; Create a queue , enqueue source vertex and mark source vertex as visited ; Standard BFS Loop ; If we find a connection to the sink node , then there is no point in BFS anymore We just have to set its parent and can return true ; We didn 't reach sink in BFS starting from source, so return false ; Returns the maximum flow from s to t in the given graph ; Create a residual graph and fill the residual graph with given capacities in the original graph as residual capacities in residual graph ; This array is filled by BFS and to store path ; There is no flow initially ; Augment the flow while tere is path from source to sink ; Find minimum residual capacity of the edges along the path filled by BFS . Or we can say find the maximum flow through the path found . ; update residual capacities of the edges and reverse edges along the path ; Add path flow to overall flow ; Return the overall flow ; Driver program to test above functions ; Let us create a graph shown in the above example\\\"\\nSolution in C++:\",\"targets\":\"#include \\n#include \\n#include \\n#include \\nusing namespace std ; #define V 6\\nbool bfs ( int rGraph [ V ] [ V ] , int s , int t , int parent [ ] ) { bool visited [ V ] ; memset ( visited , 0 , sizeof ( visited ) ) ; queue < int > q ; q . push ( s ) ; visited [ s ] = true ; parent [ s ] = -1 ; while ( ! q . empty ( ) ) { int u = q . front ( ) ; q . pop ( ) ; for ( int v = 0 ; v < V ; v ++ ) { if ( visited [ v ] == false && rGraph [ u ] [ v ] > 0 ) { if ( v == t ) { parent [ v ] = u ; return true ; } q . push ( v ) ; parent [ v ] = u ; visited [ v ] = true ; } } } return false ; } int fordFulkerson ( int graph [ V ] [ V ] , int s , int t ) { int u , v ; int rGraph [ V ] [ V ] ; for ( u = 0 ; u < V ; u ++ ) for ( v = 0 ; v < V ; v ++ ) rGraph [ u ] [ v ] = graph [ u ] [ v ] ; int parent [ V ] ; int max_flow = 0 ; while ( bfs ( rGraph , s , t , parent ) ) { int path_flow = INT_MAX ; for ( v = t ; v != s ; v = parent [ v ] ) { u = parent [ v ] ; path_flow = min ( path_flow , rGraph [ u ] [ v ] ) ; } for ( v = t ; v != s ; v = parent [ v ] ) { u = parent [ v ] ; rGraph [ u ] [ v ] -= path_flow ; rGraph [ v ] [ u ] += path_flow ; } max_flow += path_flow ; } return max_flow ; } int main ( ) { int graph [ V ] [ V ] = { { 0 , 16 , 13 , 0 , 0 , 0 } , { 0 , 0 , 10 , 12 , 0 , 0 } , { 0 , 4 , 0 , 0 , 14 , 0 } , { 0 , 0 , 9 , 0 , 0 , 20 } , { 0 , 0 , 0 , 7 , 0 , 4 } , { 0 , 0 , 0 , 0 , 0 , 0 } } ; cout << \\\" The ▁ maximum ▁ possible ▁ flow ▁ is ▁ \\\" << fordFulkerson ( graph , 0 , 5 ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Product of all the pairs from the given array | C ++ implementation to Find the product of all the pairs from the given array ; Function to calculate ( x ^ y ) % 1000000007 ; Initialize result ; Update x if it is more than or equal to p ; If y is odd , multiply x with result ; Return the final result ; Function to return the product of the elements of all possible pairs from the array ; To store the required product ; Iterate for every element of the array ; Each element appears ( 2 * n ) times ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; #define mod 1000000007\\n#define ll long long int\\nint power ( int x , unsigned int y ) { int p = 1000000007 ; 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 ; } ll productPairs ( ll arr [ ] , ll n ) { ll product = 1 ; for ( int i = 0 ; i < n ; i ++ ) { product = ( product % mod * ( int ) power ( arr [ i ] , ( 2 * n ) ) % mod ) % mod ; } return product % mod ; } int main ( ) { ll arr [ ] = { 1 , 2 , 3 } ; ll n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; cout << productPairs ( arr , n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Sum of Hamming difference of consecutive numbers from 0 to N | Set 2 | Java program to implement the above approach ; Function to calculate and return the hamming distance between all consecutive numbers from 0 to N ; Driver code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { static int TotalHammingDistance ( int n ) { int i = 1 , sum = 0 ; while ( n \\/ i > 0 ) { sum = sum + n \\/ i ; i = i * 2 ; } return sum ; } public static void main ( String [ ] args ) { int N = 9 ; System . out . println ( TotalHammingDistance ( N ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Biggest Square that can be inscribed within an Equilateral triangle | Function to find the side of the square ; the side cannot be negative ; side of the square ; Driver code\\\"\\nSolution in Python:\",\"targets\":\"def square ( a ) :\\n\\tif ( a < 0 ) :\\n\\t\\treturn - 1\\n\\tx = 0.464 * a\\n\\treturn x\\na = 5\\nprint ( square ( a ) )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Check if a number is a Trojan Number | Python 3 program to check if a number is Trojan Number or not ; Function to check if a number can be expressed as x ^ y ; Try all numbers from 2 to sqrt ( n ) as base ; Keep increasing y while power ' p ' is smaller than n . ; Function to check if a number is Strong ; count the number for each prime factor ; minimum number of prime divisors should be 2 ; Function to check if a number is Trojan Number ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"from math import sqrt , pow\\ndef isPerfectPower ( n ) :\\n\\tif n == 1 :\\n\\t\\treturn True\\n\\tfor x in range ( 2 , int ( sqrt ( n ) ) + 1 ) :\\n\\t\\ty = 2\\n\\t\\tp = pow ( x , y )\\n\\t\\twhile p <= n and p > 0 :\\n\\t\\t\\tif p == n :\\n\\t\\t\\t\\treturn True\\n\\t\\t\\ty += 1\\n\\t\\t\\tp = pow ( x , y )\\n\\treturn False\\ndef isStrongNumber ( n ) :\\n\\tcount = { i : 0 for i in range ( n ) }\\n\\twhile n % 2 == 0 :\\n\\t\\tn = n \\/\\/ 2\\n\\t\\tcount [ 2 ] += 1\\n\\tfor i in range ( 3 , int ( sqrt ( n ) ) + 1 , 2 ) :\\n\\t\\twhile n % i == 0 :\\n\\t\\t\\tn = n \\/\\/ i\\n\\t\\t\\tcount [ i ] += 1\\n\\tif n > 2 :\\n\\t\\tcount [ n ] += 1\\n\\tflag = 0\\n\\tfor key , value in count . items ( ) :\\n\\t\\tif value == 1 :\\n\\t\\t\\tflag = 1\\n\\t\\t\\tbreak\\n\\tif flag == 1 :\\n\\t\\treturn False\\n\\treturn True\\ndef isTrojan ( n ) :\\n\\treturn isPerfectPower ( n ) == False and isStrongNumber ( n )\\nif __name__ == ' _ _ main _ _ ' :\\n\\tn = 108\\n\\tif ( isTrojan ( n ) ) :\\n\\t\\tprint ( \\\" YES \\\" )\\n\\telse :\\n\\t\\tprint ( \\\" NO \\\" )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Check if Pascal 's Triangle is possible with a complete layer by using numbers upto N | Java program for the above approach ; Function to check if Pascaltriangle can be made by N integers ; Find X ; If x is integer ; Driver Code ; Given number N ; Function call\\\"\\nSolution in Java:\",\"targets\":\"class GFG { static void checkPascaltriangle ( int N ) { double x = ( Math . sqrt ( 8 * N + 1 ) - 1 ) \\/ 2 ; if ( Math . ceil ( x ) - x == 0 ) System . out . print ( \\\" Yes \\\" ) ; else System . out . print ( \\\" No \\\" ) ; } public static void main ( String [ ] args ) { int N = 10 ; checkPascaltriangle ( N ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Number of subarrays have bitwise OR >= K | Python3 program to implement the above approach ; Function which builds the segment tree ; Function that returns bitwise OR of segment [ L . . R ] ; Function to count requisite number of subarrays ; Check for subarrays starting with index i ; If OR of subarray [ i . . mid ] >= K , then all subsequent subarrays will have OR >= K therefore reduce high to mid - 1 to find the minimal length subarray [ i . . mid ] having OR >= K ; Increase count with number of subarrays having OR >= K and starting with index i ; Driver code ; Build segment tree .\\\"\\nSolution in Python:\",\"targets\":\"N = 100002\\ntree = [ 0 for i in range ( 4 * N ) ] ;\\ndef build ( arr , node , start , end ) :\\n\\tif ( start == end ) :\\n\\t\\ttree [ node ] = arr [ start ] ;\\n\\t\\treturn ;\\n\\tmid = ( start + end ) >> 1 ;\\n\\tbuild ( arr , 2 * node , start , mid ) ;\\n\\tbuild ( arr , 2 * node + 1 , mid + 1 , end ) ;\\n\\ttree [ node ] = tree [ 2 * node ] | tree [ 2 * node + 1 ] ;\\ndef query ( node , start , end , l , r ) :\\n\\tif ( start > end or start > r or end < l ) :\\n\\t\\treturn 0 ;\\n\\tif ( start >= l and end <= r ) :\\n\\t\\treturn tree [ node ] ;\\n\\tmid = ( start + end ) >> 1 ;\\n\\tq1 = query ( 2 * node , start , mid , l , r ) ;\\n\\tq2 = query ( 2 * node + 1 , mid + 1 , end , l , r ) ;\\n\\treturn q1 | q2 ;\\ndef countSubArrays ( arr , n , K ) :\\n\\tcount = 0 ;\\n\\tfor i in range ( n ) :\\n\\t\\tlow = i\\n\\t\\thigh = n - 1\\n\\t\\tindex = 1000000000\\n\\t\\twhile ( low <= high ) :\\n\\t\\t\\tmid = ( low + high ) >> 1 ;\\n\\t\\t\\tif ( query ( 1 , 0 , n - 1 , i , mid ) >= K ) :\\n\\t\\t\\t\\tindex = min ( index , mid ) ;\\n\\t\\t\\t\\thigh = mid - 1 ;\\n\\t\\t\\telse :\\n\\t\\t\\t\\tlow = mid + 1 ;\\n\\t\\tif ( index != 1000000000 ) :\\n\\t\\t\\tcount += n - index ;\\n\\treturn count ;\\nif __name__ == ' _ _ main _ _ ' :\\n\\tarr = [ 3 , 4 , 5 ]\\n\\tn = len ( arr )\\n\\tbuild ( arr , 1 , 0 , n - 1 ) ;\\n\\tk = 6 ;\\n\\tprint ( countSubArrays ( arr , n , k ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Maximum ranges that can be uniquely represented by any integer from the range | C ++ program for the above approach ; Function to find the maximum number of ranges where each range can be uniquely represented by an integer ; Sort the ranges in ascending order ; Stores the count of ranges ; Stores previously assigned range ; Traverse the vector arr [ ] ; Skip the similar ranges of size 1 ; Find the range of integer available to be assigned ; Check if an integer is available to be assigned ; Update the previously assigned range ; Update the count of range ; Return the maximum count of ranges ; Driver Code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int maxRanges ( vector < vector < int > > arr , int N ) { sort ( arr . begin ( ) , arr . end ( ) ) ; int count = 1 ; vector < int > prev = arr [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { vector < int > last = arr [ i - 1 ] ; vector < int > current = arr [ i ] ; if ( last [ 0 ] == current [ 0 ] && last [ 1 ] == current [ 1 ] && current [ 1 ] == current [ 0 ] ) continue ; int start = max ( prev [ 0 ] , current [ 0 ] - 1 ) ; int end = max ( prev [ 1 ] , current [ 1 ] ) ; if ( end - start > 0 ) { prev [ 0 ] = 1 + start ; prev [ 1 ] = end ; count ++ ; } } return count ; } int main ( ) { vector < vector < int > > range = { { 1 , 4 } , { 4 , 4 } , { 2 , 2 } , { 3 , 4 } , { 1 , 1 } } ; int N = range . size ( ) ; cout << maxRanges ( range , N ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Check if two given strings are isomorphic to each other | Javascript program for the above approach ; This function returns true if str1 and str2 are isomorphic ; Length of both strings must be same for one to one correspondence ; For counting the previous appearances of character in both the strings ; Process all characters one by one ; For string to be isomorphic the previous counts of appearances of current character in both string must be same if it is not same we return false . ; Driver Code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"let CHAR = 26 ; function isoMorphic ( str1 , str2 ) { let n = str1 . length ; let m = str2 . length ; if ( n != m ) return false ; let countChars1 = new Array ( CHAR ) ; countChars1 . fill ( 0 ) ; let countChars2 = new Array ( CHAR ) ; countChars2 . fill ( 0 ) ; for ( let i = 0 ; i < n ; i ++ ) { countChars1 [ str1 [ i ] . charCodeAt ( ) - ' ' ] ++ ; countChars2 [ str2 [ i ] . charCodeAt ( ) - ' ' ] ++ ; if ( countChars1 [ str1 [ i ] . charCodeAt ( ) - ' ' ] != countChars2 [ str2 [ i ] . charCodeAt ( ) - ' ' ] ) { return false ; } } return true ; } document . write ( isoMorphic ( \\\" \\\" , \\\" \\\" ) ? 1 + \\\" \\\" : 0 + \\\" \\\" ) ; document . write ( isoMorphic ( \\\" \\\" , \\\" \\\" ) ? 1 : 0 ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Sort the given Matrix | Memory Efficient Approach | Java implementation to sort the given matrix in strict order ; Function to sort the matrix ; Number of elements in matrix ; Loop to sort the matrix using Bubble Sort ; Condition to check if the Adjacent elements ; Swap if previous value is greater ; Loop to print the matrix ; Driver Code ; Function call to sort ; Function call to print matrix\\\"\\nHow can the above be solved in Java?\",\"targets\":\"class GFG { static void sortMat ( int [ ] [ ] data , int row , int col ) { int size = row * col ; for ( int i = 0 ; i < size ; i ++ ) { for ( int j = 0 ; j < size - 1 ; j ++ ) { if ( data [ j \\/ col ] [ j % col ] > data [ ( j + 1 ) \\/ col ] [ ( j + 1 ) % col ] ) { int temp = data [ j \\/ col ] [ j % col ] ; data [ j \\/ col ] [ j % col ] = data [ ( j + 1 ) \\/ col ] [ ( j + 1 ) % col ] ; data [ ( j + 1 ) \\/ col ] [ ( j + 1 ) % col ] = temp ; } } } } static void printMat ( int [ ] [ ] mat , int row , int col ) { for ( int i = 0 ; i < row ; i ++ ) { for ( int j = 0 ; j < col ; j ++ ) { System . out . print ( mat [ i ] [ j ] + \\\" ▁ \\\" ) ; } System . out . println ( ) ; } } public static void main ( String [ ] args ) { int [ ] [ ] mat = { { 5 , 4 , 7 } , { 1 , 3 , 8 } , { 2 , 9 , 6 } } ; int row = mat . length ; int col = mat [ 0 ] . length ; sortMat ( mat , row , col ) ; printMat ( mat , row , col ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Find triplet such that number of nodes connecting these triplets is maximum | C ++ implementation of the approach ; To store the required nodes ; Parent array to retrace the nodes ; Visited array to prevent DFS in direction on Diameter path ; DFS function to find the startnode ; DFS function to find the endnode of diameter and maintain the parent array ; DFS function to find the end node of the Longest Branch to Diameter ; Function to find the required nodes ; To find start node of diameter ; To find end node of diameter ; x is the end node of diameter ; Mark all the nodes on diameter using back tracking ; Find the end node of longest branch to diameter ; Driver code\\\"\\nSolution in C++:\",\"targets\":\"#include \\n#define ll long long int\\n#define MAX 100005\\nusing namespace std ; vector < int > adjacent [ MAX ] ; bool visited [ MAX ] ; int startnode , endnode , thirdnode ; int maxi = -1 , N ; int parent [ MAX ] ; bool vis [ MAX ] ; void dfs ( int u , int count ) { visited [ u ] = true ; int temp = 0 ; for ( int i = 0 ; i < adjacent [ u ] . size ( ) ; i ++ ) { if ( ! visited [ adjacent [ u ] [ i ] ] ) { temp ++ ; dfs ( adjacent [ u ] [ i ] , count + 1 ) ; } } if ( temp == 0 ) { if ( maxi < count ) { maxi = count ; startnode = u ; } } } void dfs1 ( int u , int count ) { visited [ u ] = true ; int temp = 0 ; for ( int i = 0 ; i < adjacent [ u ] . size ( ) ; i ++ ) { if ( ! visited [ adjacent [ u ] [ i ] ] ) { temp ++ ; parent [ adjacent [ u ] [ i ] ] = u ; dfs1 ( adjacent [ u ] [ i ] , count + 1 ) ; } } if ( temp == 0 ) { if ( maxi < count ) { maxi = count ; endnode = u ; } } } void dfs2 ( int u , int count ) { visited [ u ] = true ; int temp = 0 ; for ( int i = 0 ; i < adjacent [ u ] . size ( ) ; i ++ ) { if ( ! visited [ adjacent [ u ] [ i ] ] && ! vis [ adjacent [ u ] [ i ] ] ) { temp ++ ; dfs2 ( adjacent [ u ] [ i ] , count + 1 ) ; } } if ( temp == 0 ) { if ( maxi < count ) { maxi = count ; thirdnode = u ; } } } void findNodes ( ) { dfs ( 1 , 0 ) ; for ( int i = 0 ; i <= N ; i ++ ) visited [ i ] = false ; maxi = -1 ; dfs1 ( startnode , 0 ) ; for ( int i = 0 ; i <= N ; i ++ ) visited [ i ] = false ; int x = endnode ; vis [ startnode ] = true ; while ( x != startnode ) { vis [ x ] = true ; x = parent [ x ] ; } maxi = -1 ; for ( int i = 1 ; i <= N ; i ++ ) { if ( vis [ i ] ) dfs2 ( i , 0 ) ; } } int main ( ) { N = 4 ; adjacent [ 1 ] . push_back ( 2 ) ; adjacent [ 2 ] . push_back ( 1 ) ; adjacent [ 1 ] . push_back ( 3 ) ; adjacent [ 3 ] . push_back ( 1 ) ; adjacent [ 1 ] . push_back ( 4 ) ; adjacent [ 4 ] . push_back ( 1 ) ; findNodes ( ) ; cout << \\\" ( \\\" << startnode << \\\" , ▁ \\\" << endnode << \\\" , ▁ \\\" << thirdnode << \\\" ) \\\" ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Nearest Fibonacci Number to N | Function to find the Fibonacci number which is nearest to N ; Base Case ; Initialize the first & second terms of the Fibonacci series ; Store the third term ; Iterate until the third term is less than or equal to num ; Update the first ; Update the second ; Update the third ; Store the Fibonacci number having smaller difference with N ; Print the result ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"def nearestFibonacci ( num ) :\\n\\tif ( num == 0 ) :\\n\\t\\tprint ( 0 )\\n\\t\\treturn\\n\\tfirst = 0\\n\\tsecond = 1\\n\\tthird = first + second\\n\\twhile ( third <= num ) :\\n\\t\\tfirst = second\\n\\t\\tsecond = third\\n\\t\\tthird = first + second\\n\\tif ( abs ( third - num ) >= abs ( second - num ) ) :\\n\\t\\tans = second\\n\\telse :\\n\\t\\tans = third\\n\\tprint ( ans )\\nif __name__ == ' _ _ main _ _ ' :\\n\\tN = 17\\n\\tnearestFibonacci ( N )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Minimize cost to modify the Array such that even indices have even elements and vice versa | C # program for the above approach ; Function to find the minimum cost to modify the array according to the given criteria ; Count of wrong positioned odd and even elements ; Odd Count ; Even Count ; Swapping Cost ; Decrementing cost after swapping ; Only decrementing cost ; Return the minimum cost of the two cases ; Driver Code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; public class GFG { public static int minimumCost ( int [ ] arr , int N , int X , int Y ) { int even_count = 0 , odd_count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( ( arr [ i ] & 1 ) > 0 && ( i % 2 == 0 ) ) { odd_count ++ ; } if ( ( arr [ i ] % 2 ) == 0 && ( i & 1 ) > 0 ) { even_count ++ ; } } int cost1 = X * Math . Min ( odd_count , even_count ) ; int cost2 = Y * ( Math . Max ( odd_count , even_count ) - Math . Min ( odd_count , even_count ) ) ; int cost3 = ( odd_count + even_count ) * Y ; return Math . Min ( cost1 + cost2 , cost3 ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 5 , 3 , 7 , 2 , 1 } ; int X = 10 , Y = 2 ; int N = arr . Length ; Console . WriteLine ( minimumCost ( arr , N , X , Y ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Remove minimum number of characters so that two strings become anagram | function to calculate minimum numbers of characters to be removed to make two strings anagram ; make hash array for both string and calculate frequency of each character ; count frequency of each character in first string ; count frequency of each character in second string ; traverse count arrays to find number of characters to be removed ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function remAnagram ( $ str1 , $ str2 ) { $ count1 = array ( 26 ) ; $ count2 = array ( 26 ) ; for ( $ i = 0 ; $ i < strlen ( $ str1 ) ; $ i ++ ) $ count1 [ $ str1 [ $ i ] - ' a ' ] ++ ; for ( $ i = 0 ; $ i < strlen ( $ str2 ) ; $ i ++ ) $ count2 [ $ str2 [ $ i ] - ' a ' ] ++ ; $ result = 0 ; for ( $ i = 0 ; $ i < 26 ; $ i ++ ) $ result += abs ( $ count1 [ $ i ] - $ count2 [ $ i ] ) ; return $ result ; } { $ str1 = \\\" bcadeh \\\" ; $ str2 = \\\" hea \\\" ; echo ( remAnagram ( $ str1 , $ str2 ) ) ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Program for volume of Pyramid | Function to find the volume of triangular pyramid ; Function to find the volume of square pyramid ; Function to find the volume of pentagonal pyramid ; Function to find the volume of hexagonal pyramid ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function volumeTriangular ( $ a , $ b , $ h ) { $ vol = ( 0.1666 ) * $ a * $ b * $ h ; return $ vol ; } function volumeSquare ( $ b , $ h ) { $ vol = ( 0.33 ) * $ b * $ b * $ h ; return $ vol ; } function volumePentagonal ( $ a , $ b , $ h ) { $ vol = ( 0.83 ) * $ a * $ b * $ h ; return $ vol ; } function volumeHexagonal ( $ a , $ b , $ h ) { $ vol = $ a * $ b * $ h ; return $ vol ; } $ b = 4 ; $ h = 9 ; $ a = 4 ; echo ( \\\" Volume ▁ of ▁ triangular ▁ base ▁ pyramid ▁ is ▁ \\\" ) ; echo ( volumeTriangular ( $ a , $ b , $ h ) ) ; echo ( \\\" \\n \\\" ) ; echo ( \\\" Volume ▁ of ▁ square ▁ base ▁ pyramid ▁ is ▁ \\\" ) ; echo ( volumeSquare ( $ b , $ h ) ) ; echo ( \\\" \\n \\\" ) ; echo ( \\\" Volume ▁ of ▁ pentagonal ▁ base ▁ pyramid ▁ is ▁ \\\" ) ; echo ( volumePentagonal ( $ a , $ b , $ h ) ) ; echo ( \\\" \\n \\\" ) ; echo ( \\\" Volume ▁ of ▁ Hexagonal ▁ base ▁ pyramid ▁ is ▁ \\\" ) ; echo ( volumeHexagonal ( $ a , $ b , $ h ) ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Minimum time required to fill a cistern using N pipes | Function to calculate the time ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"def Time ( arr , n , Emptypipe ) :\\n\\tfill = 0\\n\\tfor i in range ( 0 , n ) :\\n\\t\\tfill += ( 1 \\/ arr [ i ] )\\n\\tfill = fill - ( 1 \\/ float ( Emptypipe ) )\\n\\treturn int ( 1 \\/ fill )\\nif __name__ == ' _ _ main _ _ ' :\\n\\tarr = [ 12 , 14 ]\\n\\tEmptypipe = 30\\n\\tn = len ( arr )\\n\\tprint ( ( Time ( arr , n , Emptypipe ) ) , \\\" Hours \\\" )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Efficient Program to Compute Sum of Series 1 \\/ 1 ! + 1 \\/ 2 ! + 1 \\/ 3 ! + 1 \\/ 4 ! + . . + 1 \\/ n ! | Utility function to find ; A Simple Function to return value of 1 \\/ 1 ! + 1 \\/ 2 ! + . . + 1 \\/ n ! ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function factorial ( $ n ) { $ res = 1 ; for ( $ i = 2 ; $ i <= $ n ; $ i ++ ) $ res *= $ i ; return $ res ; } function sum ( $ n ) { $ sum = 0 ; for ( $ i = 1 ; $ i <= $ n ; $ i ++ ) $ sum += 1.0 \\/ factorial ( $ i ) ; return $ sum ; } $ n = 5 ; echo ( sum ( $ n ) ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Sudo Placement [ 1.5 ] | Wolfish | Java program for SP - Wolfish ; Function to find the maxCost of path from ( n - 1 , n - 1 ) to ( 0 , 0 ) | recursive approach ; base condition ; reaches the point ; i + j ; check if it is a power of 2 , then only move diagonally ; if not a power of 2 then move side - wise ; Function to return the maximum cost ; calling dp function to get the answer ; Driver Code ; Function calling to get the answer\\\"\\nHow can the above be solved in Java?\",\"targets\":\"class GFG { static int size = 1000 ; public static int maxCost ( int [ ] [ ] a , int m , int n ) { if ( n < 0 m < 0 ) { return - 1 ; } else if ( m == 0 && n == 0 ) { return 0 ; } else { int num = m + n ; if ( ( num & ( num - 1 ) ) == 0 ) { return a [ m ] [ n ] + maxCost ( a , m - 1 , n - 1 ) ; } else { return a [ m ] [ n ] + Math . max ( maxCost ( a , m - 1 , n ) , maxCost ( a , m , n - 1 ) ) ; } } } public static int answer ( int [ ] [ ] a , int n ) { return maxCost ( a , n - 1 , n - 1 ) ; } public static void main ( String [ ] args ) { int [ ] [ ] a = new int [ ] [ ] { { 1 , 2 , 3 , 1 } , { 4 , 5 , 6 , 1 } , { 7 , 8 , 9 , 1 } , { 1 , 1 , 1 , 1 } } ; int n = 4 ; System . out . println ( answer ( a , n ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Find maximum subset sum formed by partitioning any subset of array into 2 partitions with equal sum | Java implementation for the above mentioned Dynamic Programming approach ; Function to find the maximum subset sum ; sum of all elements ; bottom up lookup table ; ; initialising dp table with INT_MIN where , INT_MIN means no solution ; Case when diff is 0 ; Putting ith element in g0 ; Putting ith element in g1 ; Ignoring ith element ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"class GFG { final static int INT_MIN = Integer . MIN_VALUE ; static int maxSum ( int a [ ] , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += a [ i ] ; int limit = 2 * sum + 1 ; int dp [ ] [ ] = new int [ n + 1 ] [ limit ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) { for ( int j = 0 ; j < limit ; j ++ ) dp [ i ] [ j ] = INT_MIN ; } dp [ 0 ] [ sum ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 0 ; j < limit ; j ++ ) { if ( ( j - a [ i - 1 ] ) >= 0 && dp [ i - 1 ] [ j - a [ i - 1 ] ] != INT_MIN ) dp [ i ] [ j ] = Math . max ( dp [ i ] [ j ] , dp [ i - 1 ] [ j - a [ i - 1 ] ] + a [ i - 1 ] ) ; if ( ( j + a [ i - 1 ] ) < limit && dp [ i - 1 ] [ j + a [ i - 1 ] ] != INT_MIN ) dp [ i ] [ j ] = Math . max ( dp [ i ] [ j ] , dp [ i - 1 ] [ j + a [ i - 1 ] ] ) ; if ( dp [ i - 1 ] [ j ] != INT_MIN ) dp [ i ] [ j ] = Math . max ( dp [ i ] [ j ] , dp [ i - 1 ] [ j ] ) ; } } return dp [ n ] [ sum ] ; } public static void main ( String [ ] args ) { int n = 4 ; int [ ] a = { 1 , 2 , 3 , 6 } ; System . out . println ( maxSum ( a , n ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"Distance between two parallel Planes in 3 | C program to find the Distance between two parallel Planes in 3 D . ; Function to find distance ; Driver Code\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#include \\nvoid distance ( float a1 , float b1 , float c1 , float d1 , float a2 , float b2 , float c2 , float d2 ) { float x1 , y1 , z1 , d ; if ( a1 \\/ a2 == b1 \\/ b2 && b1 \\/ b2 == c1 \\/ c2 ) { x1 = y1 = 0 ; z1 = - d1 \\/ c1 ; d = fabs ( ( c2 * z1 + d2 ) ) \\/ ( sqrt ( a2 * a2 + b2 * b2 + c2 * c2 ) ) ; printf ( \\\" Perpendicular ▁ distance ▁ is ▁ % f \\n \\\" , d ) ; } else printf ( \\\" Planes ▁ are ▁ not ▁ parallel \\\" ) ; return ; } int main ( ) { float a1 = 1 ; float b1 = 2 ; float c1 = -1 ; float d1 = 1 ; float a2 = 3 ; float b2 = 6 ; float c2 = -3 ; float d2 = -4 ; distance ( a1 , b1 , c1 , d1 , a2 , b2 , c2 , d2 ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Find the number of cells in the table contains X | Function to find number of cells in the table contains X ; Driver code ; Function call\\\"\\nSolution in Python:\",\"targets\":\"def Cells ( n , x ) :\\n\\tans = 0 ;\\n\\tfor i in range ( 1 , n + 1 ) :\\n\\t\\tif ( x % i == 0 and x \\/ i <= n ) :\\n\\t\\t\\tans += 1 ;\\n\\treturn ans ;\\nif __name__ == ' _ _ main _ _ ' :\\n\\tn = 6 ; x = 12 ;\\n\\tprint ( Cells ( n , x ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Breaking an Integer to get Maximum Product | Method return x ^ a in log ( a ) time ; Method returns maximum product obtained by breaking N ; Base case 2 = 1 + 1 ; Base case 3 = 2 + 1 ; Breaking based on mod with 3 ; If divides evenly , then break into all 3 ; If division gives mod as 1 , then break as 4 + power of 3 for remaining part ; If division gives mod as 2 , then break as 2 + power of 3 for remaining part ; Driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function power ( x , a ) { let res = 1 ; while ( a > 0 ) { if ( ( a & 1 ) > 0 ) res = res * x ; x = x * x ; a >>= 1 ; } return res ; } function breakInteger ( N ) { if ( N == 2 ) return 1 ; if ( N == 3 ) return 2 ; let maxProduct ; switch ( N % 3 ) { case 0 : maxProduct = power ( 3 , N \\/ 3 ) ; break ; case 1 : maxProduct = 2 * 2 * power ( 3 , ( N \\/ 3 ) - 1 ) ; break ; case 2 : maxProduct = 2 * power ( 3 , N \\/ 3 ) ; break ; } return maxProduct ; } let maxProduct = breakInteger ( 10 ) ; document . write ( maxProduct ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Generate number with given operation and check if it is palindrome | C # implementation of the approach ; Function that returns true if str is a palindrome ; Function that returns true if the generated string is a palindrome ; sub contains N as a string ; Calculate the sum of the digits ; Repeat the substring until the length of the resultant string < sum ; If length of the resultant string exceeded sum then take substring from 0 to sum - 1 ; If the generated string is a palindrome ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static bool isPalindrome ( string str ) { int len = str . Length ; for ( int i = 0 ; i < len \\/ 2 ; i ++ ) { if ( str [ i ] != str [ len - 1 - i ] ) return false ; } return true ; } static bool createStringAndCheckPalindrome ( int N ) { string sub = \\\" \\\" + N , res_str = \\\" \\\" ; int sum = 0 ; while ( N > 0 ) { int digit = N % 10 ; sum += digit ; N = N \\/ 10 ; } while ( res_str . Length < sum ) res_str += sub ; if ( res_str . Length > sum ) res_str = res_str . Substring ( 0 , sum ) ; if ( isPalindrome ( res_str ) ) return true ; return false ; } public static void Main ( ) { int N = 10101 ; if ( createStringAndCheckPalindrome ( N ) ) Console . WriteLine ( \\\" Yes \\\" ) ; else Console . WriteLine ( \\\" No \\\" ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Majority Element | C ++ Program for finding out majority element in an array ; Function to find the candidate for Majority ; Function to check if the candidate occurs more than n \\/ 2 times ; Function to print Majority Element ; Find the candidate for Majority ; Print the candidate if it is Majority ; Driver code ; Function calling\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int findCandidate ( int a [ ] , int size ) { int maj_index = 0 , count = 1 ; for ( int i = 1 ; i < size ; i ++ ) { if ( a [ maj_index ] == a [ i ] ) count ++ ; else count -- ; if ( count == 0 ) { maj_index = i ; count = 1 ; } } return a [ maj_index ] ; } bool isMajority ( int a [ ] , int size , int cand ) { int count = 0 ; for ( int i = 0 ; i < size ; i ++ ) if ( a [ i ] == cand ) count ++ ; if ( count > size \\/ 2 ) return 1 ; else return 0 ; } void printMajority ( int a [ ] , int size ) { int cand = findCandidate ( a , size ) ; if ( isMajority ( a , size , cand ) ) cout << \\\" ▁ \\\" << cand << \\\" ▁ \\\" ; else cout << \\\" No ▁ Majority ▁ Element \\\" ; } int main ( ) { int a [ ] = { 1 , 3 , 3 , 1 , 2 } ; int size = ( sizeof ( a ) ) \\/ sizeof ( a [ 0 ] ) ; printMajority ( a , size ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Pentagonal Pyramidal Number | function to get nth Pentagonal pyramidal number . ; Driver Program\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def pentagon_pyramidal ( n ) :\\n\\treturn n * n * ( n + 1 ) \\/ 2\\nn = 4\\nprint ( int ( pentagon_pyramidal ( n ) ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Set the rightmost off bit | PHP program to set the rightmost unset bit ; If all bits are set ; Set rightmost 0 bit ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function setRightmostUnsetBit ( $ n ) { if ( ( $ n & ( $ n + 1 ) ) == 0 ) return $ n ; return $ n | ( $ n + 1 ) ; } $ n = 21 ; echo setRightmostUnsetBit ( $ n ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Largest integer upto N having greatest prime factor greater than its square root | python program for the above approach ; Stores the Greatest Prime Factor ; Modified Sieve to find the Greatest Prime Factor of all integers in the range [ 1 , maxn ] ; Initialize the array with 0 ; Iterate through all values of i ; If i is not a prime number ; Update the multiples of i ; Function to find integer in the range [ 1 , N ] such that its Greatest Prime factor is greater than its square root ; Iterate through all values of i in the range [ N , 1 ] ; If greatest prime factor of i is greater than its sqare root ; Return answer ; If no valid integer exist ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"import math\\nmaxn = 100001\\ngpf = [ 0 for _ in range ( maxn ) ]\\ndef modifiedSieve ( ) :\\n\\tgpf [ 0 ] = 0\\n\\tgpf [ 1 ] = 1\\n\\tfor i in range ( 2 , maxn ) :\\n\\t\\tif ( gpf [ i ] > 0 ) :\\n\\t\\t\\tcontinue\\n\\t\\tfor j in range ( i , maxn , i ) :\\n\\t\\t\\tgpf [ j ] = max ( i , gpf [ j ] )\\ndef greatestValidInt ( N ) :\\n\\tmodifiedSieve ( )\\n\\tfor i in range ( N , 0 , - 1 ) :\\n\\t\\tif ( gpf [ i ] > math . sqrt ( i ) ) :\\n\\t\\t\\treturn i\\n\\treturn - 1\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tN = 25\\n\\tprint ( greatestValidInt ( N ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Count quadruples of given type from given array | C # program of the above approach ; lcount [ i , j ] : Stores the count of i on left of index j ; rcount [ i , j ] : Stores the count of i on right of index j ; Function to count unique elements on left and right of any index ; Find the maximum array element ; Calculate prefix sum of counts of each value ; Calculate suffix sum of counts of each value ; Function to count quadruples of the required type ; Driver Code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int maxN = 2002 ; static int [ , ] lcount = new int [ maxN , maxN ] ; static int [ , ] rcount = new int [ maxN , maxN ] ; static void fill_counts ( int [ ] a , int n ) { int i , j ; int maxA = a [ 0 ] ; for ( i = 0 ; i < n ; i ++ ) { if ( a [ i ] > maxA ) { maxA = a [ i ] ; } } for ( i = 0 ; i < n ; i ++ ) { lcount [ a [ i ] , i ] = 1 ; rcount [ a [ i ] , i ] = 1 ; } for ( i = 0 ; i <= maxA ; i ++ ) { for ( j = 1 ; j < n ; j ++ ) { lcount [ i , j ] = lcount [ i , j - 1 ] + lcount [ i , j ] ; } for ( j = n - 2 ; j >= 0 ; j -- ) { rcount [ i , j ] = rcount [ i , j + 1 ] + rcount [ i , j ] ; } } } static int countSubsequence ( int [ ] a , int n ) { int i , j ; fill_counts ( a , n ) ; int answer = 0 ; for ( i = 1 ; i < n ; i ++ ) { for ( j = i + 1 ; j < n - 1 ; j ++ ) { answer += lcount [ a [ j ] , i - 1 ] * rcount [ a [ i ] , j + 1 ] ; } } return answer ; } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 2 , 3 , 2 , 1 , 3 , 2 } ; Console . Write ( countSubsequence ( a , a . Length ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Hyperfactorial of a number | C # program to find the hyperfactorial of a number using boost libraries ; function to calculate the value of hyperfactorial ; initialise the val to 1 ; 1 ^ 1 * 2 ^ 2 * 3 ^ 3. . . . ; returns the hyperfactorial of a number ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static int boost_hyperfactorial ( int num ) { int val = 1 ; for ( int i = 1 ; i <= num ; i ++ ) { for ( int j = 1 ; j <= i ; j ++ ) { val *= i ; } } return val ; } public static void Main ( ) { int num = 5 ; Console . WriteLine ( boost_hyperfactorial ( num ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Encrypt string with product of number of vowels and consonants in substring of size k | isVowel ( ) is a function that returns true for a vowel and false otherwise . ; function to Encrypt the dtring ; for each substring ; substring of size k ; counting number of vowels and consonants ; append product to answer . ; Driven Program\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function isVowel ( c ) { return ( c == ' ' c == ' ' c == ' ' c == ' ' c == ' ' ) ; } function encryptString ( s , n , k ) { var countVowels = 0 ; var countConsonants = 0 ; var ans = \\\" \\\" ; for ( var l = 0 ; l <= n - k ; l ++ ) { countVowels = 0 ; countConsonants = 0 ; for ( var r = l ; r <= l + k - 1 ; r ++ ) { if ( isVowel ( s [ r ] ) == true ) countVowels ++ ; else countConsonants ++ ; } ans += ( countVowels * countConsonants ) . toString ( ) ; } return ans ; } var s = \\\" \\\" ; var n = s . length ; var k = 2 ; document . write ( encryptString ( s , n , k ) ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"Permutation Coefficient | A Dynamic Programming based solution that uses table P [ ] [ ] to calculate the Permutation Coefficient ; Returns value of Permutation Coefficient P ( n , k ) ; Calculate value of Permutation Coefficient in bottom up manner ; Base Cases ; Calculate value using previosly stored values ; This step is important as P ( i , j ) = 0 for j > i ; Driver Code\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint permutationCoeff ( int n , int k ) { int P [ n + 1 ] [ k + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= std : : min ( i , k ) ; j ++ ) { if ( j == 0 ) P [ i ] [ j ] = 1 ; else P [ i ] [ j ] = P [ i - 1 ] [ j ] + ( j * P [ i - 1 ] [ j - 1 ] ) ; P [ i ] [ j + 1 ] = 0 ; } } return P [ n ] [ k ] ; } int main ( ) { int n = 10 , k = 2 ; printf ( \\\" Value ▁ of ▁ P ( % d , ▁ % d ) ▁ is ▁ % d ▁ \\\" , n , k , permutationCoeff ( n , k ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Construct an array from its pair | Python3 implementation of the approach ; Utility function to print the array ; Function to generate the original array from the pair - product array ; First element of the resulting array ; Find all the other elements ; Print the elements of the generated array ; Driver code\\\"\\nSolution in Python:\",\"targets\":\"from math import sqrt\\ndef printArr ( arr , n ) :\\n\\tfor i in range ( n ) :\\n\\t\\tprint ( arr [ i ] , end = \\\" ▁ \\\" ) ;\\ndef constructArr ( pair , n ) :\\n\\tsize = int ( ( 1 + sqrt ( 1 + 8 * n ) ) \\/\\/ 2 ) ;\\n\\tarr = [ 0 ] * ( size ) ;\\n\\tarr [ 0 ] = int ( sqrt ( ( pair [ 0 ] * pair [ 1 ] ) \\/ pair [ size - 1 ] ) ) ;\\n\\tfor i in range ( 1 , size ) :\\n\\t\\tarr [ i ] = pair [ i - 1 ] \\/\\/ arr [ 0 ] ;\\n\\tprintArr ( arr , size ) ;\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tpair = [ 48 , 18 , 24 , 24 , 32 , 12 ] ;\\n\\tn = len ( pair ) ;\\n\\tconstructArr ( pair , n ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Program to find HCF ( Highest Common Factor ) of 2 Numbers | C # program to find GCD of two numbers ; Recursive function to return gcd of a and b ; Everything divides 0 ; base case ; a is greater ; Driver method\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int gcd ( int a , int b ) { if ( a == 0 && b == 0 ) return 0 ; if ( a == 0 ) return b ; if ( b == 0 ) return a ; if ( a == b ) return a ; if ( a > b ) return gcd ( a - b , b ) ; return gcd ( a , b - a ) ; } public static void Main ( ) { int a = 98 , b = 56 ; Console . WriteLine ( \\\" GCD ▁ of ▁ \\\" + a + \\\" ▁ and ▁ \\\" + b + \\\" ▁ is ▁ \\\" + gcd ( a , b ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Linear Search | Python3 code to linearly search x in arr [ ] . If x is present then return its location , otherwise return - 1 ; Driver Code ; Function call\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def search ( arr , n , x ) :\\n\\tfor i in range ( 0 , n ) :\\n\\t\\tif ( arr [ i ] == x ) :\\n\\t\\t\\treturn i\\n\\treturn - 1\\narr = [ 2 , 3 , 4 , 10 , 40 ]\\nx = 10\\nn = len ( arr )\\nresult = search ( arr , n , x )\\nif ( result == - 1 ) :\\n\\tprint ( \\\" Element ▁ is ▁ not ▁ present ▁ in ▁ array \\\" )\\nelse :\\n\\tprint ( \\\" Element ▁ is ▁ present ▁ at ▁ index \\\" , result )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Find maximum unreachable height using two ladders | C ++ implementation of the approach ; Function to return the maximum height which can 't be reached ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int maxHeight ( int h1 , int h2 ) { return ( ( h1 * h2 ) - h1 - h2 ) ; } int main ( ) { int h1 = 7 , h2 = 5 ; cout << max ( 0 , maxHeight ( h1 , h2 ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Gijswijt 's Sequence | if the sequence is a ( 1 ) a ( 2 ) a ( 3 ) . . a ( n - 1 ) check if the sequence can be represented as x * ( y ^ k ) find the largest value of k ; count ; pattern of elements of size i from the end of sequence ; count ; extract the pattern in a reverse order ; check how many times the pattern is repeated ; if the element dosent match ; if the end of pattern is reached set value of k = 0 and increase the count ; return the max count ; print first n terms of Gijswijt 's sequence ; set the count ; stoes the element ; print the first n terms of the sequence ; push the element ; find the count for next number ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def find_count ( ele ) :\\n\\tcount = 0\\n\\tfor i in range ( len ( ele ) ) :\\n\\t\\tp = [ ]\\n\\t\\tc = 0\\n\\t\\tj = len ( ele ) - 1\\n\\t\\twhile j >= ( len ( ele ) - 1 - i ) and j >= 0 :\\n\\t\\t\\tp . append ( ele [ j ] )\\n\\t\\t\\tj -= 1\\n\\t\\tj = len ( ele ) - 1\\n\\t\\tk = 0\\n\\t\\twhile j >= 0 :\\n\\t\\t\\tif ele [ j ] != p [ k ] :\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tj -= 1\\n\\t\\t\\tk += 1\\n\\t\\t\\tif k == len ( p ) :\\n\\t\\t\\t\\tc += 1\\n\\t\\t\\t\\tk = 0\\n\\t\\tcount = max ( count , c )\\n\\treturn count\\ndef solve ( n ) :\\n\\tcount = 1\\n\\tele = [ ]\\n\\tfor i in range ( n ) :\\n\\t\\tprint ( count , end = \\\" ▁ \\\" )\\n\\t\\tele . append ( count )\\n\\t\\tcount = find_count ( ele )\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tn = 10\\n\\tsolve ( n )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Find all elements in array which have at | C ++ program to find all elements in array which have atleast two greater elements itself . ; If current element is smaller than first then update both first and second ; If arr [ i ] is in between first and second then update second ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; void findElements ( int arr [ ] , int n ) { int first = INT_MIN , second = INT_MIN ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > first ) { second = first ; first = arr [ i ] ; } else if ( arr [ i ] > second ) second = arr [ i ] ; } for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] < second ) cout << arr [ i ] << \\\" ▁ \\\" ; } int main ( ) { int arr [ ] = { 2 , -6 , 3 , 5 , 1 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; findElements ( arr , n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Toggle first and last bits of a number | Returns a number which has same bit count as n and has only first and last bits as set . ; set all the bit of the number ; Adding one to n now unsets all bits and moves MSB to one place . Now we shift the number by 1 and add 1. ; if number is 1 ; take XOR with first and last set bit number ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function takeLandFsetbits ( $ n ) { $ n |= $ n >> 1 ; $ n |= $ n >> 2 ; $ n |= $ n >> 4 ; $ n |= $ n >> 8 ; $ n |= $ n >> 16 ; return ( ( $ n + 1 ) >> 1 ) + 1 ; } function toggleFandLbits ( int $ n ) { if ( $ n == 1 ) return 0 ; return $ n ^ takeLandFsetbits ( $ n ) ; } $ n = 10 ; echo toggleFandLbits ( $ n ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Linear Search | Javascript program for linear search ; Run loop from 0 to right ; If search_element is found with left variable ; If search_element is found with right variable ; If element not found ; Driver code ; Function call\\\"\\nSolution in Javascript:\",\"targets\":\"function search ( arr , search_Element ) { let left = 0 ; let length = arr . length ; let right = length - 1 ; let position = - 1 ; for ( left = 0 ; left <= right ; ) { if ( arr [ left ] == search_Element ) { position = left ; document . write ( \\\" \\\" + ( position + 1 ) + \\\" \\\" + ( left + 1 ) + \\\" \\\" ) ; break ; } if ( arr [ right ] == search_Element ) { position = right ; document . write ( \\\" \\\" + ( position + 1 ) + \\\" \\\" + ( length - right ) + \\\" \\\" ) ; break ; } left ++ ; right -- ; } if ( position == - 1 ) document . write ( \\\" \\\" + left + \\\" \\\" ) ; } let arr = [ 1 , 2 , 3 , 4 , 5 ] ; let search_element = 5 ; search ( arr , search_element ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Print reverse string after removing vowels | Function for replacing the string ; initialize a string of length n ; Traverse through all characters of string ; assign the value to string r from last index of string s ; if s [ i ] is a consonant then print r [ i ] ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"def replaceOriginal ( s , n ) :\\n\\tr = [ ' ▁ ' ] * n\\n\\tfor i in range ( n ) :\\n\\t\\tr [ i ] = s [ n - 1 - i ]\\n\\t\\tif ( s [ i ] != ' a ' and s [ i ] != ' e ' and s [ i ] != ' i ' and s [ i ] != ' o ' and s [ i ] != ' u ' ) :\\n\\t\\t\\tprint ( r [ i ] , end = \\\" \\\" )\\n\\tprint ( )\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\ts = \\\" geeksforgeeks \\\"\\n\\tn = len ( s )\\n\\treplaceOriginal ( s , n )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Sum of even values and update queries on an array | C ++ implementation of the approach ; Function to return the sum of even elements after updating value at given index ; Add given value to A [ index ] ; To store the sum of even elements ; If current element is even ; Function to print the result for every query ; Resultant vector that stores the result for every query ; Get sum of even elements after updating value at given index ; Store sum for each query ; Print the result for every query ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int EvenSum ( vector < int > & A , int index , int value ) { A [ index ] = A [ index ] + value ; int sum = 0 ; for ( int i = 0 ; i < A . size ( ) ; i ++ ) if ( A [ i ] % 2 == 0 ) sum = sum + A [ i ] ; return sum ; } void BalanceArray ( vector < int > & A , vector < vector < int > > & Q ) { vector < int > ANS ; int i , sum ; for ( i = 0 ; i < Q . size ( ) ; i ++ ) { int index = Q [ i ] [ 0 ] ; int value = Q [ i ] [ 1 ] ; sum = EvenSum ( A , index , value ) ; ANS . push_back ( sum ) ; } for ( i = 0 ; i < ANS . size ( ) ; i ++ ) cout << ANS [ i ] << \\\" ▁ \\\" ; } int main ( ) { vector < int > A = { 1 , 2 , 3 , 4 } ; vector < vector < int > > Q = { { 0 , 1 } , { 1 , -3 } , { 0 , -4 } , { 3 , 2 } } ; BalanceArray ( A , Q ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Find the minimum cost to reach destination using a train | A Dynamic Programming based solution to find min cost to reach station N - 1 from station 0. ; A recursive function to find the shortest path from source ' s ' to destination ' d ' . This function returns the smallest possible cost to reach station N - 1 from station 0. ; dist [ i ] stores minimum cost to reach station i from station 0. ; Go through every station and check if using it as an intermediate station gives better path ; Driver program to test above function\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int INF = int . MaxValue , N = 4 ; static int minCost ( int [ , ] cost ) { int [ ] dist = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) dist [ i ] = INF ; dist [ 0 ] = 0 ; for ( int i = 0 ; i < N ; i ++ ) for ( int j = i + 1 ; j < N ; j ++ ) if ( dist [ j ] > dist [ i ] + cost [ i , j ] ) dist [ j ] = dist [ i ] + cost [ i , j ] ; return dist [ N - 1 ] ; } public static void Main ( ) { int [ , ] cost = { { 0 , 15 , 80 , 90 } , { INF , 0 , 40 , 50 } , { INF , INF , 0 , 70 } , { INF , INF , INF , 0 } } ; Console . WriteLine ( \\\" The ▁ Minimum ▁ cost ▁ to \\\" + \\\" ▁ reach ▁ station ▁ \\\" + N + \\\" ▁ is ▁ \\\" + minCost ( cost ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Convert a given tree to its Sum Tree | ; A tree node structure ; Convert a given tree to a tree where every node contains sum of values of nodes in left and right subtrees in the original tree ; Base case ; Store the old value ; Recursively call for left and right subtrees and store the sum as new value of this node ; Return the sum of values of nodes in left and right subtrees and old_value of this node ; A utility function to print inorder traversal of a Binary Tree ; Utility function to create a new Binary Tree node ; Driver function to test above functions ; Constructing tree given in the above figure ; Print inorder traversal of the converted tree to test result of toSumTree ( )\\\"\\nSolution in C:\",\"targets\":\"#include \\nstruct node { int data ; struct node * left ; struct node * right ; } ; int toSumTree ( struct node * node ) { if ( node == NULL ) return 0 ; int old_val = node -> data ; node -> data = toSumTree ( node -> left ) + toSumTree ( node -> right ) ; return node -> data + old_val ; } void printInorder ( struct node * node ) { if ( node == NULL ) return ; printInorder ( node -> left ) ; printf ( \\\" % d ▁ \\\" , node -> data ) ; printInorder ( node -> right ) ; } struct node * newNode ( int data ) { struct node * temp = new struct node ; temp -> data = data ; temp -> left = NULL ; temp -> right = NULL ; return temp ; } int main ( ) { struct node * root = NULL ; int x ; root = newNode ( 10 ) ; root -> left = newNode ( -2 ) ; root -> right = newNode ( 6 ) ; root -> left -> left = newNode ( 8 ) ; root -> left -> right = newNode ( -4 ) ; root -> right -> left = newNode ( 7 ) ; root -> right -> right = newNode ( 5 ) ; toSumTree ( root ) ; printf ( \\\" Inorder ▁ Traversal ▁ of ▁ the ▁ resultant ▁ tree ▁ is : ▁ \\n \\\" ) ; printInorder ( root ) ; getchar ( ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Minimum number of squares whose sum equals to given number n | C # program for the above approach ; Function to count minimum squares that sum to n ; Creating visited vector of size n + 1 ; Queue of pair to store node and number of steps ; Initially ans variable is initialized with inf ; Push starting node with 0 0 indicate current number of step to reach n ; Mark starting node visited ; If node reaches its destination 0 update it with answer ; Loop for all possible path from 1 to i * i <= current node ( p . first ) ; If we are standing at some node then next node it can jump to will be current node - ( some square less than or equal n ) ; Check if it is valid and not visited yet ; Mark visited ; Push it it Queue ; Return ans to calling function ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; using System . Collections ; using System . Collections . Generic ; class GFG { public class Point { public int x , y ; public Point ( int x , int y ) { this . x = x ; this . y = y ; } } public static int numSquares ( int n ) { int [ ] visited = new int [ n + 1 ] ; Queue q = new Queue ( ) ; int ans = 1000000000 ; q . Enqueue ( new Point ( n , 0 ) ) ; visited [ n ] = 1 ; while ( q . Count != 0 ) { Point p = ( Point ) q . Dequeue ( ) ; if ( p . x == 0 ) ans = Math . Min ( ans , p . y ) ; for ( int i = 1 ; i * i <= p . x ; i ++ ) { int path = ( p . x - ( i * i ) ) ; if ( path >= 0 && ( visited [ path ] == 0 path == 0 ) ) { visited [ path ] = 1 ; q . Enqueue ( new Point ( path , p . y + 1 ) ) ; } } } return ans ; } public static void Main ( string [ ] args ) { Console . Write ( numSquares ( 12 ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Program to find the angles of a quadrilateral | Driver code ; according to formula derived above ; print all the angles\\\"\\nSolution in php:\",\"targets\":\"< ? php $ d = 10 ; $ a = ( 360 - ( 6 * $ d ) ) \\/ 4 ; echo $ a , \\\" , ▁ \\\" , $ a + $ d , \\\" , ▁ \\\" , $ a + ( 2 * $ d ) , \\\" , ▁ \\\" , $ a + ( 3 * $ d ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Generate all binary strings without consecutive 1 's | Java program to Generate all binary string without consecutive 1 's of size K ; Array conversion to String -- ; Base Condition when we reached at the end of Array * * ; Printing the Generated String * * Return to the previous case * ; If the first Character is Zero then adding * * ; If the Character is One then add Zero to next * * ; Calling Recursively for the next value of Array ; Initializing first character to Zero ; Generating Strings starting with Zero -- ; Initialized first Character to one -- ; Calling function fun with argument k ; This code is Contributed by Praveen Tiwari\\\"\\nSolution in Java:\",\"targets\":\"import java . util . * ; import java . lang . * ; public class BinaryS { public static String toString ( char [ ] a ) { String string = new String ( a ) ; return string ; } static void generate ( int k , char [ ] ch , int n ) { if ( n == k ) { System . out . print ( toString ( ch ) + \\\" ▁ \\\" ) ; return ; } if ( ch [ n - 1 ] == '0' ) { ch [ n ] = '0' ; generate ( k , ch , n + 1 ) ; ch [ n ] = '1' ; generate ( k , ch , n + 1 ) ; } if ( ch [ n - 1 ] == '1' ) { ch [ n ] = '0' ; generate ( k , ch , n + 1 ) ; } } static void fun ( int k ) { if ( k <= 0 ) { return ; } char [ ] ch = new char [ k ] ; ch [ 0 ] = '0' ; generate ( k , ch , 1 ) ; ch [ 0 ] = '1' ; generate ( k , ch , 1 ) ; } public static void main ( String args [ ] ) { int k = 3 ; fun ( k ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Sum of numbers from 1 to N which are divisible by 3 or 4 | Function to calculate the sum of numbers divisible by 3 or 4 ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function sum ( $ N ) { $ S1 ; $ S2 ; $ S3 ; $ S1 = ( ( $ N \\/ 3 ) ) * ( 2 * 3 + ( $ N \\/ 3 - 1 ) * 3 ) \\/ 2 ; $ S2 = ( ( $ N \\/ 4 ) ) * ( 2 * 4 + ( $ N \\/ 4 - 1 ) * 4 ) \\/ 2 ; $ S3 = ( ( $ N \\/ 12 ) ) * ( 2 * 12 + ( $ N \\/ 12 - 1 ) * 12 ) \\/ 2 ; return $ S1 + $ S2 - $ S3 ; } $ N = 20 ; echo sum ( 12 ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Find a Fixed Point ( Value equal to index ) in a given array | C program to check fixed point in an array using binary search ; low + ( high - low ) \\/ 2 ; ; Return - 1 if there is no Fixed Point ; Driver program to check above functions\\\"\\nSolution in C:\",\"targets\":\"#include \\nint binarySearch ( int arr [ ] , int low , int high ) { if ( high >= low ) { int mid = ( low + high ) \\/ 2 ; if ( mid == arr [ mid ] ) return mid ; if ( mid > arr [ mid ] ) return binarySearch ( arr , ( mid + 1 ) , high ) ; else return binarySearch ( arr , low , ( mid - 1 ) ) ; } return -1 ; } int main ( ) { int arr [ 10 ] = { -10 , -1 , 0 , 3 , 10 , 11 , 30 , 50 , 100 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; printf ( \\\" Fixed ▁ Point ▁ is ▁ % d \\\" , binarySearch ( arr , 0 , n - 1 ) ) ; getchar ( ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Sudo Placement [ 1.5 ] | Wolfish | C # program for SP - Wolfish ; Function to find the maxCost of path from ( n - 1 , n - 1 ) to ( 0 , 0 ) | recursive approach ; base condition ; reaches the point ; i + j ; check if it is a power of 2 , then only move diagonally ; if not a power of 2 then move side - wise ; Function to return the maximum cost ; calling dp function to get the answer ; Driver Code ; Function calling to get the answer\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int size = 1000 ; public static int maxCost ( int [ , ] a , int m , int n ) { if ( n < 0 m < 0 ) return - 1 ; else if ( m == 0 && n == 0 ) return 0 ; else { int num = m + n ; if ( ( num & ( num - 1 ) ) == 0 ) return a [ m , n ] + maxCost ( a , m - 1 , n - 1 ) ; else return a [ m , n ] + Math . Max ( maxCost ( a , m - 1 , n ) , maxCost ( a , m , n - 1 ) ) ; } } public static int answer ( int [ , ] a , int n ) { return maxCost ( a , n - 1 , n - 1 ) ; } static void Main ( ) { int [ , ] a = new int [ , ] { { 1 , 2 , 3 , 1 } , { 4 , 5 , 6 , 1 } , { 7 , 8 , 9 , 1 } , { 1 , 1 , 1 , 1 } } ; int n = 4 ; Console . Write ( answer ( a , n ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Dynamic Programming | High | A DP based C ++ program to find maximum tasks . ; Returns the maximum among the 2 numbers ; Returns maximum amount of task that can be done till day n ; An array task_dp that stores the maximum task done ; If n = 0 , no solution exists ; If n = 1 , high effort task on that day will be the solution ; Fill the entire array determining which task to choose on day i ; Driver program to test above function\\\"\\nSolution in C:\",\"targets\":\"#include \\nint max ( int x , int y ) { return ( x > y ? x : y ) ; } int maxTasks ( int high [ ] , int low [ ] , int n ) { int task_dp [ n + 1 ] ; task_dp [ 0 ] = 0 ; task_dp [ 1 ] = high [ 0 ] ; for ( int i = 2 ; i <= n ; i ++ ) task_dp [ i ] = max ( high [ i - 1 ] + task_dp [ i - 2 ] , low [ i - 1 ] + task_dp [ i - 1 ] ) ; return task_dp [ n ] ; } int main ( ) { int n = 5 ; int high [ ] = { 3 , 6 , 8 , 7 , 6 } ; int low [ ] = { 1 , 5 , 4 , 5 , 3 } ; printf ( \\\" % d \\\" , maxTasks ( high , low , n ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Generate all numbers up to N in Lexicographical Order | C ++ program for the above approach ; Driver code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; void dfs ( int temp , int n , vector < int > & sol ) ; void lexNumbers ( int n ) { vector < int > sol ; dfs ( 1 , n , sol ) ; cout << \\\" [ \\\" << sol [ 0 ] ; for ( int i = 1 ; i < sol . size ( ) ; i ++ ) cout << \\\" , ▁ \\\" << sol [ i ] ; cout << \\\" ] \\\" ; } void dfs ( int temp , int n , vector < int > & sol ) { if ( temp > n ) return ; sol . push_back ( temp ) ; dfs ( temp * 10 , n , sol ) ; if ( temp % 10 != 9 ) dfs ( temp + 1 , n , sol ) ; } int main ( ) { int n = 15 ; lexNumbers ( n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Count elements of same value placed at same indices of two given arrays | Function to count maximum matched elements from the arrays A [ ] and B [ ] ; Stores position of elements of array A [ ] in the array B [ ] ; Keep track of difference between the indices ; Traverse the array A [ ] ; Traverse the array B [ ] ; If difference is negative , add N to it ; Keep track of the number of shifts required to place elements at same indices ; Return the max matches ; Driver Code ; Returns the count of matched elements\\\"\\nSolution in Python:\",\"targets\":\"def maxMatch ( A , B ) :\\n\\tAindex = { }\\n\\tdiff = { }\\n\\tfor i in range ( len ( A ) ) :\\n\\t\\tAindex [ A [ i ] ] = i\\n\\tfor i in range ( len ( B ) ) :\\n\\t\\tif i - Aindex [ B [ i ] ] < 0 :\\n\\t\\t\\tif len ( A ) + i - Aindex [ B [ i ] ] not in diff :\\n\\t\\t\\t\\tdiff [ len ( A ) + i - Aindex [ B [ i ] ] ] = 1\\n\\t\\t\\telse :\\n\\t\\t\\t\\tdiff [ len ( A ) + i - Aindex [ B [ i ] ] ] += 1\\n\\t\\telse :\\n\\t\\t\\tif i - Aindex [ B [ i ] ] not in diff :\\n\\t\\t\\t\\tdiff [ i - Aindex [ B [ i ] ] ] = 1\\n\\t\\t\\telse :\\n\\t\\t\\t\\tdiff [ i - Aindex [ B [ i ] ] ] += 1\\n\\treturn max ( diff . values ( ) )\\nA = [ 5 , 3 , 7 , 9 , 8 ]\\nB = [ 8 , 7 , 3 , 5 , 9 ]\\nprint ( maxMatch ( A , B ) )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Sort an Array which contain 1 to N values in O ( N ) using Cycle Sort | C ++ program for the above approach ; Function to swap two a & b value ; Function to print array element ; Traverse the array ; Function to sort the array in O ( N ) ; Traverse the array ; If the current element is at correct position ; Else swap the current element with it 's correct position ; Driver Code ; Function call to sort the array ; Function call to print the array\\\"\\nSolution in C++:\",\"targets\":\"#include \\\" bits \\/ stdc + + . h \\\"\\nusing namespace std ; void swap ( int * a , int * b ) { int temp = * a ; * a = * b ; * b = temp ; } void printArray ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { cout << arr [ i ] << ' ▁ ' ; } } void sortArray ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; ) { if ( arr [ i ] == i + 1 ) { i ++ ; } else { swap ( & arr [ i ] , & arr [ arr [ i ] - 1 ] ) ; } } } int main ( ) { int arr [ ] = { 2 , 1 , 5 , 3 , 4 } ; int N = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; sortArray ( arr , N ) ; printArray ( arr , N ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Average of a stream of numbers | ; Returns the new average after including x ; Prints average of a stream of numbers ; Driver program to test above functions\\\"\\nSolution in C:\",\"targets\":\"#include \\nfloat getAvg ( int x ) { static int sum , n ; sum += x ; return ( ( ( float ) sum ) \\/ ++ n ) ; } void streamAvg ( float arr [ ] , int n ) { float avg = 0 ; for ( int i = 0 ; i < n ; i ++ ) { avg = getAvg ( arr [ i ] ) ; printf ( \\\" Average ▁ of ▁ % d ▁ numbers ▁ is ▁ % f ▁ \\n \\\" , i + 1 , avg ) ; } return ; } int main ( ) { float arr [ ] = { 10 , 20 , 30 , 40 , 50 , 60 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; streamAvg ( arr , n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"How to turn on a particular bit in a number ? | Returns a number that has all bits same as n except the k 'th bit which is made 1 ; k must be greater than 0 ; Do | of n with a number with all unset bits except the k 'th bit ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function turnOnK ( $ n , $ k ) { if ( $ k <= 0 ) return $ n ; return ( $ n | ( 1 << ( $ k - 1 ) ) ) ; } $ n = 4 ; $ k = 2 ; echo turnOnK ( $ n , $ k ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Maximum sum of distinct numbers such that LCM of these numbers is N | Returns maximum sum of numbers with LCM as N ; Initialize result ; Finding a divisor of n and adding it to max_sum ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function maxSumLCM ( $ n ) { $ max_sum = 0 ; for ( $ i = 1 ; $ i * $ i <= $ n ; $ i ++ ) { if ( $ n % $ i == 0 ) { $ max_sum += $ i ; if ( $ n \\/ $ i != $ i ) $ max_sum += ( $ n \\/ $ i ) ; } } return $ max_sum ; } $ n = 2 ; echo MaxSumLCM ( $ n ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Find the smallest and second smallest elements in an array | Function to print first smallest and second smallest elements ; There should be atleast two elements ; If current element is smaller than first then update both first and second ; If arr [ i ] is in between first and second then update second ; Driver program\\\"\\nSolution in Javascript:\",\"targets\":\"function print2Smallest ( arr , arr_size ) { let i , first , second ; if ( arr_size < 2 ) { document . write ( \\\" \\\" ) ; return ; } first = Number . MAX_VALUE ; second = Number . MAX_VALUE ; for ( i = 0 ; i < arr_size ; i ++ ) { if ( arr [ i ] < first ) { second = first ; first = arr [ i ] ; } else if ( arr [ i ] < second && arr [ i ] != first ) second = arr [ i ] ; } if ( second == Number . MAX_VALUE ) document . write ( \\\" \\\" ) ; else document . write ( \\\" \\\" + first + \\\" \\\" + \\\" \\\" + second + ' ' ) ; } let arr = [ 12 , 13 , 1 , 10 , 34 , 1 ] ; let n = arr . length ; print2Smallest ( arr , n ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"Identical Linked Lists | A recursive C function to check if two linked lists are identical or not ; If both lists are empty ; If both lists are not empty , then data of current nodes must match , and same should be recursively true for rest of the nodes . ; If we reach here , then one of the lists is empty and other is not\\nHow can the above be solved in C?\",\"targets\":\"bool areIdentical ( struct Node * a , struct Node * b ) { if ( a == NULL && b == NULL ) return true ; if ( a != NULL && b != NULL ) return ( a -> data == b -> data ) && areIdentical ( a -> next , b -> next ) ; return false ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Find the n | Efficient C program to find n - th palindrome ; Construct the nth binary palindrome with the given group number , aux_number and operation type ; No need to insert any bit in the middle ; Length of the final binary representation ; Fill first and last bit as 1 ; Start filling the a [ ] from middle , with the aux_num binary representation ; Get the auxiliary number 's ith bit and fill around middle ; Insert bit 0 in the middle ; Length of the final binary representation ; Fill first and last bit as 1 ; Start filling the a [ ] from middle , with the aux_num binary representation ; Get the auxiliary number 's ith bit and fill around middle ; else Insert bit 1 in the middle ; Length of the final binary representation ; Fill first and last bit as 1 ; Start filling the a [ ] from middle , with the aux_num binary representation ; Get the auxiliary number 's ith bit and fill around middle ; Convert the number to decimal from binary ; Will return the nth binary palindrome number ; Add number of elements in all the groups , until the group of the nth number is found ; Total number of elements until this group ; Element 's offset position in the group ; Finding which bit to be placed in the middle and finding the number , which we will fill from the middle in both directions ; We need to fill this auxiliary number in binary form the middle in both directions ; op = 0 ; Need to Insert 0 at middle ; op = 1 ; Need to Insert 1 at middle ; Driver code ; Function Call\\\"\\nSolution in C:\",\"targets\":\"#include \\n#define INT_SIZE 32\\nint constructNthNumber ( int group_no , int aux_num , int op ) { int a [ INT_SIZE ] = { 0 } ; int num = 0 , len_f ; int i = 0 ; if ( op == 2 ) { len_f = 2 * group_no ; a [ len_f - 1 ] = a [ 0 ] = 1 ; while ( aux_num ) { a [ group_no + i ] = a [ group_no - 1 - i ] = aux_num & 1 ; aux_num = aux_num >> 1 ; i ++ ; } } else if ( op == 0 ) { len_f = 2 * group_no + 1 ; a [ len_f - 1 ] = a [ 0 ] = 1 ; a [ group_no ] = 0 ; while ( aux_num ) { a [ group_no + 1 + i ] = a [ group_no - 1 - i ] = aux_num & 1 ; aux_num = aux_num >> 1 ; i ++ ; } } { len_f = 2 * group_no + 1 ; a [ len_f - 1 ] = a [ 0 ] = 1 ; a [ group_no ] = 1 ; while ( aux_num ) { a [ group_no + 1 + i ] = a [ group_no - 1 - i ] = aux_num & 1 ; aux_num = aux_num >> 1 ; i ++ ; } } for ( i = 0 ; i < len_f ; i ++ ) num += ( 1 << i ) * a [ i ] ; return num ; } int getNthNumber ( int n ) { int group_no = 0 , group_offset ; int count_upto_group = 0 , count_temp = 1 ; int op , aux_num ; while ( count_temp < n ) { group_no ++ ; count_upto_group = count_temp ; count_temp += 3 * ( 1 << ( group_no - 1 ) ) ; } group_offset = n - count_upto_group - 1 ; if ( ( group_offset + 1 ) <= ( 1 << ( group_no - 1 ) ) ) { aux_num = group_offset ; } else { if ( ( ( group_offset + 1 ) - ( 1 << ( group_no - 1 ) ) ) % 2 ) else aux_num = ( ( group_offset ) - ( 1 << ( group_no - 1 ) ) ) \\/ 2 ; } return constructNthNumber ( group_no , aux_num , op ) ; } int main ( ) { int n = 9 ; printf ( \\\" % d \\\" , getNthNumber ( n ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Length of longest increasing subsequence in a string | Java program for the above approach ; Function to find length of longest increasing subsequence in a string ; Stores at every i - th index , the length of the longest increasing subsequence ending with character i ; Size of string ; Stores the length of LIS ; Iterate over each character of the string ; Store position of the current character ; Stores the length of LIS ending with current character ; Check for all characters less then current character ; Include current character ; Update length of longest increasing subsequence ; Updating LIS for current character ; Return the length of LIS ; Driver Code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { static int mn = - 2147483648 ; static int lisOtimised ( String s ) { int [ ] dp = new int [ 30 ] ; Arrays . fill ( dp , 0 ) ; int N = s . length ( ) ; int lis = mn ; for ( int i = 0 ; i < N ; i ++ ) { int val = ( int ) s . charAt ( i ) - 97 ; int curr = 0 ; for ( int j = 0 ; j < val ; j ++ ) { curr = Math . max ( curr , dp [ j ] ) ; } curr ++ ; lis = Math . max ( lis , curr ) ; dp [ val ] = Math . max ( dp [ val ] , curr ) ; } return lis ; } public static void main ( String [ ] args ) { String s = \\\" fdryutiaghfse \\\" ; System . out . print ( lisOtimised ( s ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Coin Change | DP | Dynamic Programming PHP implementation of Coin Change problem ; table [ i ] will be storing the number of solutions for value i . We need n + 1 rows as the table is constructed in bottom up manner using the base case ( n = 0 ) ; Base case ( If given value is 0 ) ; Pick all coins one by one and update the table [ ] values after the index greater than or equal to the value of the picked coin ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function count_1 ( & $ S , $ m , $ n ) { $ table = array_fill ( 0 , $ n + 1 , NULl ) ; $ table [ 0 ] = 1 ; for ( $ i = 0 ; $ i < $ m ; $ i ++ ) for ( $ j = $ S [ $ i ] ; $ j <= $ n ; $ j ++ ) $ table [ $ j ] += $ table [ $ j - $ S [ $ i ] ] ; return $ table [ $ n ] ; } $ arr = array ( 1 , 2 , 3 ) ; $ m = sizeof ( $ arr ) ; $ n = 4 ; $ x = count_1 ( $ arr , $ m , $ n ) ; echo $ x ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"Find a Fixed Point ( Value equal to index ) in a given array | C program to check fixed point in an array using linear search ; If no fixed point present then return - 1 ; Driver program to check above functions\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint linearSearch ( int arr [ ] , int n ) { int i ; for ( i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == i ) return i ; } return -1 ; } int main ( ) { int arr [ ] = { -10 , -1 , 0 , 3 , 10 , 11 , 30 , 50 , 100 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; printf ( \\\" Fixed ▁ Point ▁ is ▁ % d \\\" , linearSearch ( arr , n ) ) ; getchar ( ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Check divisibility of binary string by 2 ^ k | function to check whether given binary number is evenly divisible by 2 ^ k or not ; count of number of 0 from last ; if count = k , number is evenly divisible , so returns true else false ; first example ; Second example\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def isDivisible ( str , k ) :\\n\\tn = len ( str )\\n\\tc = 0\\n\\tfor i in range ( 0 , k ) :\\n\\t\\tif ( str [ n - i - 1 ] == '0' ) :\\n\\t\\t\\tc += 1\\n\\treturn ( c == k )\\nstr1 = \\\"10101100\\\"\\nk = 2\\nif ( isDivisible ( str1 , k ) ) :\\n\\tprint ( \\\" Yes \\\" )\\nelse :\\n\\tprint ( \\\" No \\\" )\\nstr2 = \\\"111010100\\\"\\nk = 2\\nif ( isDivisible ( str2 , k ) ) :\\n\\tprint ( \\\" Yes \\\" )\\nelse :\\n\\tprint ( \\\" No \\\" )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Minimize number of cuts required to break N length stick into N unit length sticks | C # program to find minimum time required to split a stick of N length into unit pieces ; Function to return the minimum time required to split stick of N into length into unit pieces ; Return the minimum unit of time required ; Driver Code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int min_time_to_cut ( int N ) { if ( N == 0 ) return 0 ; return ( int ) Math . Ceiling ( Math . Log ( N ) \\/ Math . Log ( 2 ) ) ; } public static void Main ( ) { int N = 100 ; Console . Write ( min_time_to_cut ( N ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Permutation Coefficient | Returns value of Permutation Coefficient P ( n , k ) ; base case ; Calculate value factorials up to n ; P ( n , k ) = n ! \\/ ( n - k ) ! ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function permutationCoeff ( $ n , $ k ) { $ fact = array ( ) ; $ fact [ 0 ] = 1 ; for ( $ i = 1 ; $ i <= $ n ; $ i ++ ) $ fact [ $ i ] = $ i * $ fact [ $ i - 1 ] ; return $ fact [ $ n ] \\/ $ fact [ $ n - $ k ] ; } $ n = 10 ; $ k = 2 ; echo \\\" Value ▁ of ▁ P ( \\\" , $ n , \\\" ▁ \\\" , $ k , \\\" ) ▁ is ▁ \\\" , permutationCoeff ( $ n , $ k ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Queries on count of points lie inside a circle | Python 3 program to find number of points lie inside or on the circumference of circle for Q queries . ; Computing the x ^ 2 + y ^ 2 for each given points and sorting them . ; Return count of points lie inside or on circumference of circle using binary search on p [ 0. . n - 1 ] ; Driver Code ; Compute distances of all points and keep the distances sorted so that query can work in O ( logn ) using Binary Search . ; Print number of points in a circle of radius 3. ; Print number of points in a circle of radius 32.\\\"\\nHow can the above be solved in Python?\",\"targets\":\"import math\\ndef preprocess ( p , x , y , n ) :\\n\\tfor i in range ( n ) :\\n\\t\\tp [ i ] = x [ i ] * x [ i ] + y [ i ] * y [ i ]\\n\\tp . sort ( )\\ndef query ( p , n , rad ) :\\n\\tstart = 0\\n\\tend = n - 1\\n\\twhile ( ( end - start ) > 1 ) :\\n\\t\\tmid = ( start + end ) \\/\\/ 2\\n\\t\\ttp = math . sqrt ( p [ mid ] )\\n\\t\\tif ( tp > ( rad * 1.0 ) ) :\\n\\t\\t\\tend = mid - 1\\n\\t\\telse :\\n\\t\\t\\tstart = mid\\n\\ttp1 = math . sqrt ( p [ start ] )\\n\\ttp2 = math . sqrt ( p [ end ] )\\n\\tif ( tp1 > ( rad * 1.0 ) ) :\\n\\t\\treturn 0\\n\\telif ( tp2 <= ( rad * 1.0 ) ) :\\n\\t\\treturn end + 1\\n\\telse :\\n\\t\\treturn start + 1\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tx = [ 1 , 2 , 3 , - 1 , 4 ]\\n\\ty = [ 1 , 2 , 3 , - 1 , 4 ]\\n\\tn = len ( x )\\n\\tp = [ 0 ] * n\\n\\tpreprocess ( p , x , y , n )\\n\\tprint ( query ( p , n , 3 ) )\\n\\tprint ( query ( p , n , 32 ) )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"Largest gap in an array | A C program to find largest gap between two elements in an array . ; function to solve the given problem ; Driver Code\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#include \\n#include \\nint solve ( int a [ ] , int n ) { int max1 = INT_MIN ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( abs ( a [ i ] - a [ j ] ) > max1 ) { max1 = abs ( a [ i ] - a [ j ] ) ; } } } return max1 ; } int main ( ) { int arr [ ] = { -1 , 2 , 3 , -4 , -10 , 22 } ; int size = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; printf ( \\\" Largest ▁ gap ▁ is ▁ : ▁ % d \\\" , solve ( arr , size ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Binomial Coefficient | DP | Returns value of Binomial Coefficient C ( n , k ) ; Base Cases ; Recur ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function binomialCoeff ( $ n , $ k ) { if ( $ k > $ n ) return 0 ; if ( $ k == 0 $ k == $ n ) return 1 ; return binomialCoeff ( $ n - 1 , $ k - 1 ) + binomialCoeff ( $ n - 1 , $ k ) ; } $ n = 5 ; $ k = 2 ; echo \\\" Value ▁ of ▁ C \\\" , \\\" ( \\\" , $ n , $ k , \\\" ) ▁ is ▁ \\\" , binomialCoeff ( $ n , $ k ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Find the real and imaginary part of a Complex number | Function to find real and imaginary parts of a complex number ; string length stored in variable l ; variable for the index of the separator ; Storing the index of '+ ; else storing the index of '- ; Finding the real part of the complex number ; Finding the imaginary part of the complex number ; Driver code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def findRealAndImag ( s ) :\\n\\tl = len ( s )\\n\\ti = 0\\n'\\n\\tif ( s . find ( ' + ' ) != - 1 ) :\\n\\t\\ti = s . find ( ' + ' )\\n'\\n\\telse :\\n\\t\\ti = s . find ( ' - ' ) ;\\n\\treal = s [ : i ]\\n\\timaginary = s [ i + 1 : l - 1 ]\\n\\tprint ( \\\" Real ▁ part : \\\" , real )\\n\\tprint ( \\\" Imaginary ▁ part : \\\" , imaginary )\\ns = \\\"3 + 4i \\\" ;\\nfindRealAndImag ( s ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Number of Subsequences with Even and Odd Sum | C # implementation to find the number of Subsequences with Even and Odd Sum ; Arrays to store the count of even subsequences and odd subsequences ; Initialising countEVEN [ 0 ] and countODD [ 0 ] to 0 since as there is no subsequence before the iteration with even or odd count . ; Here countODD [ i ] denotes count of odd subsequences till i ; if the number is even ; if the number is odd ; Driver Code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { public static int [ ] countSum ( int [ ] arr , int n ) { int [ ] countODD = new int [ n + 1 ] ; int [ ] countEVEN = new int [ n + 1 ] ; countODD [ 0 ] = 0 ; countEVEN [ 0 ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( arr [ i - 1 ] % 2 == 0 ) { countEVEN [ i ] = countEVEN [ i - 1 ] + countEVEN [ i - 1 ] + 1 ; countODD [ i ] = countODD [ i - 1 ] + countODD [ i - 1 ] ; } else { countEVEN [ i ] = countEVEN [ i - 1 ] + countODD [ i - 1 ] ; countODD [ i ] = countODD [ i - 1 ] + countEVEN [ i - 1 ] + 1 ; } } int [ ] ans = new int [ 2 ] ; ans [ 0 ] = countEVEN [ n ] ; ans [ 1 ] = countODD [ n ] ; return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = new int [ ] { 1 , 2 , 2 , 3 } ; int n = 4 ; int [ ] ans = countSum ( arr , n ) ; Console . WriteLine ( \\\" EvenSum ▁ = ▁ \\\" + ans [ 0 ] ) ; Console . WriteLine ( \\\" OddSum ▁ = ▁ \\\" + ans [ 1 ] ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Ways to split array into two groups of same XOR value | Return the count number of ways to split array into two groups such that each group has equal XOR value . ; We can split only if XOR is 0. Since XOR of all is 0 , we can consider all subsets as one group . ; Driver Program\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function countgroup ( a , n ) { var xs = 0 ; for ( var i = 0 ; i < n ; i ++ ) xs = xs ^ a [ i ] ; if ( xs == 0 ) return ( 1 << ( n - 1 ) ) - 1 ; } var a = [ 1 , 2 , 3 ] ; var n = a . length ; document . write ( countgroup ( a , n ) + \\\" \\\" ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Lexicographically largest possible String after removal of K characters | Python3 program to implement the above approach ; Final result string ; If the current char exceeds the character at the top of the stack ; Remove from the end of the string ; Decrease k for the removal ; Insert current character ; Perform remaining K deletions from the end of the string ; Return the string ; Driver code\\\"\\nSolution in Python:\",\"targets\":\"def largestString ( num , k ) :\\n\\tans = [ ]\\n\\tfor i in range ( len ( num ) ) :\\n\\t\\twhile ( len ( ans ) and ans [ - 1 ] < num [ i ] and k > 0 ) :\\n\\t\\t\\tans . pop ( )\\n\\t\\t\\tk -= 1\\n\\t\\tans . append ( num [ i ] )\\n\\twhile ( len ( ans ) and k ) :\\n\\t\\tk -= 1\\n\\t\\tans . pop ( )\\n\\treturn ans\\nstr = \\\" zyxedcba \\\"\\nk = 1\\nprint ( * largestString ( str , k ) , sep = \\\" \\\" )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Check if a cell can be visited more than once in a String | Function to check if any cell can be visited more than once ; Array to mark cells ; Traverse the string ; Increase the visit count of the left and right cells within the array which can be visited ; If any cell can be visited more than once , Return True ; Driver code\\\"\\nSolution in php:\",\"targets\":\"< ? php function checkIfOverlap ( $ str ) { $ len = strlen ( $ str ) ; $ visited = array_fill ( 0 , $ len + 1 , NULL ) ; for ( $ i = 0 ; $ i < $ len ; $ i ++ ) { if ( $ str [ $ i ] == ' . ' ) continue ; for ( $ j = max ( 0 , $ i - $ str [ $ i ] ) ; $ j <= min ( $ len , $ i + $ str [ $ i ] ) ; $ j ++ ) $ visited [ $ j ] ++ ; } for ( $ i = 0 ; $ i < $ len ; $ i ++ ) { if ( $ visited [ $ i ] > 1 ) { return true ; } } return false ; } $ str = \\\" . 2 . . 2 . \\\" ; if ( checkIfOverlap ( $ str ) ) echo \\\" YES \\\" ; else echo \\\" NO \\\" ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Maximum sum of difference of adjacent elements | C # program to find maximum sum of adjacent elements of permutation of n ; To find max sum of permutation ; Base case ; Otherwise max sum will be ( n * ( n - 1 ) \\/ 2 ) - 1 + n \\/ 2 ; Driver program to test maxSum ( )\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; public class main { static int maxSum ( int n ) { if ( n == 1 ) return 1 ; else return ( n * ( n - 1 ) \\/ 2 ) - 1 + n \\/ 2 ; } public static void Main ( ) { int n = 3 ; Console . WriteLine ( maxSum ( n ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Coin Change | DP | Recursive C program for coin change problem . ; Returns the count of ways we can sum S [ 0. . . m - 1 ] coins to get sum n ; If n is 0 then there is 1 solution ( do not include any coin ) ; If n is less than 0 then no solution exists ; If there are no coins and n is greater than 0 , then no solution exist ; count is sum of solutions ( i ) including S [ m - 1 ] ( ii ) excluding S [ m - 1 ] ; Driver program to test above function\\\"\\nSolution in C:\",\"targets\":\"#include \\nint count ( int S [ ] , int m , int n ) { if ( n == 0 ) return 1 ; if ( n < 0 ) return 0 ; if ( m <= 0 && n >= 1 ) return 0 ; return count ( S , m - 1 , n ) + count ( S , m , n - S [ m - 1 ] ) ; } int main ( ) { int i , j ; int arr [ ] = { 1 , 2 , 3 } ; int m = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; printf ( \\\" % d ▁ \\\" , count ( arr , m , 4 ) ) ; getchar ( ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Center element of matrix equals sums of half diagonals | PHP Program to check if the center element is equal to the individual sum of all the half diagonals ; Function to Check center element is equal to the individual sum of all the half diagonals ; Find sums of half diagonals ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php $ MAX = 100 ; function HalfDiagonalSums ( $ mat , $ n ) { global $ MAX ; $ diag1_left = 1 ; $ diag1_right = 1 ; $ diag2_left = 1 ; $ diag2_right = 1 ; for ( $ 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 ] ) ; } $ a = array ( array ( 2 , 9 , 1 , 4 , -2 ) , array ( 6 , 7 , 2 , 11 , 4 ) , array ( 4 , 2 , 9 , 2 , 4 ) , array ( 1 , 9 , 2 , 4 , 4 ) , array ( 0 , 2 , 4 , 2 , 5 ) ) ; if ( HalfDiagonalSums ( $ a , 5 ) == 0 ) echo \\\" Yes \\\" ; else echo \\\" No \\\" ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Count the number of times a Bulb switches its state | C ++ program for the above approach ; Function to find the number of times a bulb switches its state ; Count of 1 s ; Traverse the array ; Update count of 1 s ; Update the status of bulb ; Traverse the array Q [ ] ; Stores previous state of the bulb ; Toggle the switch and update count of 1 s ; If the bulb switches state ; Return count ; Driver Code ; Input ; Queries ; Function call to find number of times the bulb toggles\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int solve ( int A [ ] , int n , int Q [ ] , int q ) { int one = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( A [ i ] == 1 ) one ++ ; int glows = 0 , count = 0 ; if ( one >= ceil ( n \\/ 2 ) ) glows = 1 ; for ( int i = 0 ; i < q ; i ++ ) { int prev = glows ; if ( A [ Q [ i ] - 1 ] == 1 ) one -- ; if ( A [ Q [ i ] - 1 ] == 0 ) one ++ ; A [ Q [ i ] - 1 ] ^= 1 ; if ( one >= ceil ( n \\/ 2.0 ) ) { glows = 1 ; } else { glows = 0 ; } if ( prev != glows ) count ++ ; } return count ; } int main ( ) { int n = 3 ; int arr [ ] = { 1 , 1 , 0 } ; int q = 3 ; int Q [ ] = { 3 , 2 , 1 } ; cout << solve ( arr , n , Q , q ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Find politeness of a number | A function to count all odd prime factors of a given number n ; Eliminate all even prime factor of number of n ; n must be odd at this point , so iterate for only odd numbers till sqrt ( n ) ; if i divides n , then start counting of Odd divisors ; If n odd prime still remains then count it ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function countOddPrimeFactors ( $ n ) { $ result = 1 ; while ( $ n % 2 == 0 ) $ n \\/= 2 ; for ( $ i = 3 ; $ i * $ i <= $ n ; $ i += 2 ) { $ divCount = 0 ; while ( $ n % $ i == 0 ) { $ n \\/= $ i ; ++ $ divCount ; } $ result *= $ divCount + 1 ; } if ( $ n > 2 ) $ result *= 2 ; return $ result ; } function politness ( $ n ) { return countOddPrimeFactors ( $ n ) - 1 ; } $ n = 90 ; echo \\\" Politness ▁ of ▁ \\\" , $ n , \\\" ▁ = ▁ \\\" , politness ( $ n ) , \\\" \\n \\\" ; $ n = 15 ; echo \\\" Politness ▁ of ▁ \\\" , $ n , \\\" ▁ = ▁ \\\" , politness ( $ n ) , \\\" \\n \\\" ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Longest Common Subsequence | DP | Returns length of LCS for X [ 0. . m - 1 ] , Y [ 0. . n - 1 ] ; Driver program to test the above function\\\"\\nSolution in Python:\",\"targets\":\"def lcs ( X , Y , m , n ) :\\n\\tif m == 0 or n == 0 :\\n\\treturn 0 ;\\n\\telif X [ m - 1 ] == Y [ n - 1 ] :\\n\\treturn 1 + lcs ( X , Y , m - 1 , n - 1 ) ;\\n\\telse :\\n\\treturn max ( lcs ( X , Y , m , n - 1 ) , lcs ( X , Y , m - 1 , n ) ) ;\\nX = \\\" AGGTAB \\\"\\nY = \\\" GXTXAYB \\\"\\nprint \\\" Length ▁ of ▁ LCS ▁ is ▁ \\\" , lcs ( X , Y , len ( X ) , len ( Y ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Count of ways in which N can be represented as sum of Fibonacci numbers without repetition | C # program for the above approach ; Function to generate the fibonacci number ; First two number of fibonacci sqequence ; Function to find maximum ways to represent num as the sum of fibonacci number ; Generate the Canonical form of given number ; Reverse the number ; Base condition of dp1 and dp2 ; Iterate from 1 to cnt ; Calculate dp1 [ ] ; Calculate dp2 [ ] ; Return final ans ; Driver code ; Function call to generate the fibonacci numbers ; Given number ; Function call\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static long [ ] fib = new long [ 101 ] ; static long [ ] dp1 = new long [ 101 ] ; static long [ ] dp2 = new long [ 101 ] ; static long [ ] v = new long [ 101 ] ; static void fibonacci ( ) { fib [ 1 ] = 1 ; fib [ 2 ] = 2 ; for ( int i = 3 ; i <= 87 ; i ++ ) { fib [ i ] = fib [ i - 1 ] + fib [ i - 2 ] ; } } static long find ( long num ) { int cnt = 0 ; for ( int i = 87 ; i > 0 ; i -- ) { if ( num >= fib [ i ] ) { v [ cnt ++ ] = i ; num -= fib [ i ] ; } } for ( int i = 0 ; i < cnt \\/ 2 ; i ++ ) { long t = v [ i ] ; v [ i ] = v [ cnt - i - 1 ] ; v [ cnt - i - 1 ] = t ; } dp1 [ 0 ] = 1 ; dp2 [ 0 ] = ( v [ 0 ] - 1 ) \\/ 2 ; for ( int i = 1 ; i < cnt ; i ++ ) { dp1 [ i ] = dp1 [ i - 1 ] + dp2 [ i - 1 ] ; dp2 [ i ] = ( ( v [ i ] - v [ i - 1 ] ) \\/ 2 ) * dp2 [ i - 1 ] + ( ( v [ i ] - v [ i - 1 ] - 1 ) \\/ 2 ) * dp1 [ i - 1 ] ; } return ( dp1 [ cnt - 1 ] + dp2 [ cnt - 1 ] ) ; } static void Main ( ) { fibonacci ( ) ; int num = 13 ; Console . Write ( find ( num ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Maximum subarray sum in an array created after repeated concatenation | C # program to print largest contiguous array sum when array is created after concatenating a small array k times . ; Returns sum of maximum sum subarray created after concatenating a [ 0. . n - 1 ] k times . ; This is where it differs from Kadane 's algorithm. We use modular arithmetic to find next element. ; Driver Code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int maxSubArraySumRepeated ( int [ ] a , int n , int k ) { int max_so_far = 0 ; int max_ending_here = 0 ; for ( int i = 0 ; i < n * k ; i ++ ) { max_ending_here = max_ending_here + a [ i % n ] ; if ( max_so_far < max_ending_here ) max_so_far = max_ending_here ; if ( max_ending_here < 0 ) max_ending_here = 0 ; } return max_so_far ; } public static void Main ( ) { int [ ] a = { 10 , 20 , - 30 , - 1 } ; int n = a . Length ; int k = 3 ; Console . Write ( \\\" Maximum ▁ contiguous ▁ sum ▁ is ▁ \\\" + maxSubArraySumRepeated ( a , n , k ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Minimum cost of reducing Array by merging any adjacent elements repetitively | Python3 program for the above approach ; Function to find the total minimum cost of merging two consecutive numbers ; Find the size of numbers [ ] ; If array is empty , return 0 ; To store the prefix Sum of numbers array numbers [ ] ; Traverse numbers [ ] to find the prefix sum ; dp table to memoised the value ; For single numbers cost is zero ; Iterate for length >= 1 ; Find sum in range [ i . . j ] ; Initialise dp [ i ] [ j ] to _MAX ; Iterate for all possible K to find the minimum cost ; Update the minimum sum ; Return the final minimum cost ; Given set of numbers ; Function call\\\"\\nHow can the above be solved in Python?\",\"targets\":\"import sys\\ndef mergeTwoNumbers ( numbers ) :\\n\\tn = len ( numbers )\\n\\tif ( len ( numbers ) == 0 ) :\\n\\t\\treturn 0\\n\\tprefixSum = [ 0 ] * ( n + 1 )\\n\\tfor i in range ( 1 , n + 1 ) :\\n\\t\\tprefixSum [ i ] = ( prefixSum [ i - 1 ] + numbers [ i - 1 ] )\\n\\tdp = [ [ 0 for i in range ( n + 1 ) ] for j in range ( n + 1 ) ]\\n\\tfor i in range ( 1 , n + 1 ) :\\n\\t\\tdp [ i ] [ i ] = 0\\n\\tfor p in range ( 2 , n + 1 ) :\\n\\t\\tfor i in range ( 1 , n - p + 2 ) :\\n\\t\\t\\tj = i + p - 1\\n\\t\\t\\tsum = prefixSum [ j ] - prefixSum [ i - 1 ]\\n\\t\\t\\tdp [ i ] [ j ] = sys . maxsize\\n\\t\\t\\tfor k in range ( i , j ) :\\n\\t\\t\\t\\tdp [ i ] [ j ] = min ( dp [ i ] [ j ] , ( dp [ i ] [ k ] + dp [ k + 1 ] [ j ] + sum ) )\\n\\treturn dp [ 1 ] [ n ]\\narr1 = [ 6 , 4 , 4 , 6 ]\\nprint ( mergeTwoNumbers ( arr1 ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Split first N natural numbers into two sets with minimum absolute difference of their sums | C ++ program to implement the above approach ; Function to split the first N natural numbers into two sets having minimum absolute difference of their sums ; Driver Code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int minAbsDiff ( int N ) { if ( N % 4 == 0 N % 4 == 3 ) { return 0 ; } return 1 ; } int main ( ) { int N = 6 ; cout << minAbsDiff ( N ) ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Convert a String to an Integer using Recursion | C # implementation of the approach ; Recursive function to convert string to integer ; If the number represented as a string contains only a single digit then returns its value ; Recursive call for the sub - string starting at the second character ; First digit of the number ; First digit multiplied by the appropriate power of 10 and then add the recursive result For example , xy = ( ( x * 10 ) + y ) ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static int stringToInt ( String str ) { if ( str . Length == 1 ) return ( str [ 0 ] - '0' ) ; double y = stringToInt ( str . Substring ( 1 ) ) ; double x = str [ 0 ] - '0' ; x = x * Math . Pow ( 10 , str . Length - 1 ) + y ; return ( int ) ( x ) ; } public static void Main ( String [ ] args ) { String str = \\\"1235\\\" ; Console . Write ( stringToInt ( str ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Mean of array generated by products of all pairs of the given array | C ++ program for the above approach ; Function to find the mean of pair product array of arr [ ] ; Store product of pairs ; Generate all unordered pairs ; Store product of pairs ; Size of pairArray ; Store sum of pairArray ; Stores the mean of pairArray [ ] ; Find mean of pairArray [ ] ; Return the resultant mean ; Driver Code ; Given array arr [ ] ; Function Call\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; float pairProductMean ( int arr [ ] , int N ) { vector < int > pairArray ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { int pairProduct = arr [ i ] * arr [ j ] ; pairArray . push_back ( pairProduct ) ; } } int length = pairArray . size ( ) ; float sum = 0 ; for ( int i = 0 ; i < length ; i ++ ) sum += pairArray [ i ] ; float mean ; if ( length != 0 ) mean = sum \\/ length ; else mean = 0 ; return mean ; } int main ( ) { int arr [ ] = { 1 , 2 , 4 , 8 } ; int N = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; cout << fixed << setprecision ( 2 ) << pairProductMean ( arr , N ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Smallest sum contiguous subarray | Set | Function to find the smallest sum contiguous subarray ; First invert the sign of the elements ; Apply the normal Kadane algorithm but on the elements of the array having inverted sign ; Invert the answer to get minimum val ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function smallestSumSubarr ( $ arr , $ n ) { for ( $ i = 0 ; $ i < $ n ; $ i ++ ) $ arr [ $ i ] = - $ arr [ $ i ] ; $ sum_here = $ arr [ 0 ] ; $ max_sum = $ arr [ 0 ] ; for ( $ i = 1 ; $ i < $ n ; $ i ++ ) { $ sum_here = max ( $ sum_here + $ arr [ $ i ] , $ arr [ $ i ] ) ; $ max_sum = max ( $ max_sum , $ sum_here ) ; } return ( -1 ) * $ max_sum ; } $ arr = array ( 3 , -4 , 2 , -3 , -1 , 7 , -5 ) ; $ n = sizeof ( $ arr ) ; echo \\\" Smallest ▁ sum : ▁ \\\" , smallestSumSubarr ( $ arr , $ n ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Check if a string has all characters with same frequency with one variation allowed | To check a string S can be converted to a variation string ; Run loop form 0 to length of string ; declaration of variables ; if first is true than countOfVal1 increase ; if second is true than countOfVal2 increase ; Driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function checkForVariation ( str ) { if ( str == null str . length == 0 ) { return true ; } let map = new Map ( ) ; for ( let i = 0 ; i < str . length ; i ++ ) { if ( ! map . has ( str [ i ] ) ) map . set ( str [ i ] , 0 ) ; map . set ( str [ i ] , map . get ( str [ i ] ) + 1 ) ; } let first = true , second = true ; let val1 = 0 , val2 = 0 ; let countOfVal1 = 0 , countOfVal2 = 0 ; for ( let [ key , value ] of map . entries ( ) ) { let i = value ; if ( first ) { val1 = i ; first = false ; countOfVal1 ++ ; continue ; } if ( i == val1 ) { countOfVal1 ++ ; continue ; } if ( second ) { val2 = i ; countOfVal2 ++ ; second = false ; continue ; } if ( i == val2 ) { countOfVal2 ++ ; continue ; } return false ; } if ( countOfVal1 > 1 && countOfVal2 > 1 ) { return false ; } else { return true ; } } document . write ( checkForVariation ( \\\" \\\" ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Longest Common Subsequence | DP | Dynamic Programming C implementation of LCS problem ; Returns length of LCS for X [ 0. . m - 1 ] , Y [ 0. . n - 1 ] ; Following steps build L [ m + 1 ] [ n + 1 ] in bottom up fashion . Note that L [ i ] [ j ] contains length of LCS of X [ 0. . i - 1 ] and Y [ 0. . j - 1 ] ; L [ m ] [ n ] contains length of LCS for X [ 0. . n - 1 ] and Y [ 0. . m - 1 ] ; Utility function to get max of 2 integers ; Driver program to test above function\\\"\\nSolution in C:\",\"targets\":\"#include \\nint max ( int a , int b ) ; int lcs ( char * X , char * Y , int m , int n ) { int L [ m + 1 ] [ n + 1 ] ; int i , j ; for ( i = 0 ; i <= m ; i ++ ) { for ( j = 0 ; j <= n ; j ++ ) { if ( i == 0 j == 0 ) L [ i ] [ j ] = 0 ; else if ( X [ i - 1 ] == Y [ j - 1 ] ) L [ i ] [ j ] = L [ i - 1 ] [ j - 1 ] + 1 ; else L [ i ] [ j ] = max ( L [ i - 1 ] [ j ] , L [ i ] [ j - 1 ] ) ; } } return L [ m ] [ n ] ; } int max ( int a , int b ) { return ( a > b ) ? a : b ; } int main ( ) { char X [ ] = \\\" AGGTAB \\\" ; char Y [ ] = \\\" GXTXAYB \\\" ; int m = strlen ( X ) ; int n = strlen ( Y ) ; printf ( \\\" Length ▁ of ▁ LCS ▁ is ▁ % d \\\" , lcs ( X , Y , m , n ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Integers from the range that are composed of a single distinct digit | Boolean function to check distinct digits of a number ; Take last digit ; Check if all other digits are same as last digit ; Remove last digit ; Function to return the count of integers that are composed of a single distinct digit only ; If i has single distinct digit ; Driver code\\\"\\nSolution in php:\",\"targets\":\"< ? php function checkDistinct ( $ x ) { $ last = $ x % 10 ; while ( $ x ) { if ( $ x % 10 != $ last ) return false ; $ x = floor ( $ x \\/ 10 ) ; } return true ; } function findCount ( $ L , $ R ) { $ count = 0 ; for ( $ i = $ L ; $ i <= $ R ; $ i ++ ) { if ( checkDistinct ( $ i ) ) $ count += 1 ; } return $ count ; } $ L = 10 ; $ R = 50 ; echo findCount ( $ L , $ R ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Missing occurrences of a number in an array such that maximum absolute difference of adjacent elements is minimum | Python3 implementation of the missing number such that maximum absolute difference between adjacent element is minimum ; Function to find the missing number such that maximum absolute difference is minimum ; Loop to find the maximum and minimum adjacent element to missing number ; Driver Code ; Function call\\\"\\nHow can the above be solved in Python?\",\"targets\":\"import sys\\ndef missingnumber ( n , arr ) -> int :\\n\\tmn = sys . maxsize ;\\n\\tmx = - sys . maxsize - 1 ;\\n\\tfor i in range ( n ) :\\n\\t\\tif ( i > 0 and arr [ i ] == - 1 and arr [ i - 1 ] != - 1 ) :\\n\\t\\t\\tmn = min ( mn , arr [ i - 1 ] ) ;\\n\\t\\t\\tmx = max ( mx , arr [ i - 1 ] ) ;\\n\\t\\tif ( i < ( n - 1 ) and arr [ i ] == - 1 and arr [ i + 1 ] != - 1 ) :\\n\\t\\t\\tmn = min ( mn , arr [ i + 1 ] ) ;\\n\\t\\t\\tmx = max ( mx , arr [ i + 1 ] ) ;\\n\\tres = ( mx + mn ) \\/ 2 ;\\n\\treturn res ;\\nif __name__ == ' _ _ main _ _ ' :\\n\\tn = 5 ;\\n\\tarr = [ - 1 , 10 , - 1 , 12 , - 1 ] ;\\n\\tres = missingnumber ( n , arr ) ;\\n\\tprint ( res ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Probability of Euler 's Totient Function in a range [L, R] to be divisible by M | C ++ Program to implement the above approach ; Seieve of Erotosthenes to compute all primes ; If prime ; Mark all its multiples as non - prime ; Function to find the probability of Euler 's Totient Function in a given range ; Initializing two arrays with values from L to R for Euler 's totient ; Indexing from 0 ; If the current number is prime ; Checking if i is prime factor of numbers in range L to R ; Update all the numbers which has prime factor i ; If number in range has a prime factor > sqrt ( number ) ; Count those which are divisible by M ; Return the result ; Driver Code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; #define size 1000001\\nvoid seiveOfEratosthenes ( int * prime ) { prime [ 0 ] = 1 , prime [ 1 ] = 0 ; for ( int i = 2 ; i * i < 1000001 ; i ++ ) { if ( prime [ i ] == 0 ) { for ( int j = i * i ; j < 1000001 ; j += i ) { prime [ j ] = 1 ; } } } } float probabiltyEuler ( int * prime , int L , int R , int M ) { int * arr = new int [ size ] { 0 } ; int * eulerTotient = new int [ size ] { 0 } ; int count = 0 ; for ( int i = L ; i <= R ; i ++ ) { eulerTotient [ i - L ] = i ; arr [ i - L ] = i ; } for ( int i = 2 ; i < 1000001 ; i ++ ) { if ( prime [ i ] == 0 ) { for ( int j = ( L \\/ i ) * i ; j <= R ; j += i ) { if ( j - L >= 0 ) { eulerTotient [ j - L ] = eulerTotient [ j - L ] \\/ i * ( i - 1 ) ; while ( arr [ j - L ] % i == 0 ) { arr [ j - L ] \\/= i ; } } } } } for ( int i = L ; i <= R ; i ++ ) { if ( arr [ i - L ] > 1 ) { eulerTotient [ i - L ] = ( eulerTotient [ i - L ] \\/ arr [ i - L ] ) * ( arr [ i - L ] - 1 ) ; } } for ( int i = L ; i <= R ; i ++ ) { if ( ( eulerTotient [ i - L ] % M ) == 0 ) { count ++ ; } } return ( 1.0 * count \\/ ( R + 1 - L ) ) ; } int main ( ) { int * prime = new int [ size ] { 0 } ; seiveOfEratosthenes ( prime ) ; int L = 1 , R = 7 , M = 3 ; cout << probabiltyEuler ( prime , L , R , M ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Subtract two numbers without using arithmetic operators | PHP Program to subtract two Number without using arithmetic operator ; Iterate till there is no carry ; borrow contains common set bits of y and unset bits of x ; Subtraction of bits of x and y where at least one of the bits is not set ; Borrow is shifted by one so that subtracting it from x gives the required sum ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function subtract ( $ x , $ y ) { while ( $ y != 0 ) { $ borrow = ( ~ $ x ) & $ y ; $ x = $ x ^ $ y ; $ y = $ borrow << 1 ; } return $ x ; } $ x = 29 ; $ y = 13 ; echo \\\" x ▁ - ▁ y ▁ is ▁ \\\" , subtract ( $ x , $ y ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Reverse words in a given string | C program for above approach : ; temp is for word boundary ; STEP 1 of the above algorithm ; This condition is to make sure that the string start with valid character ( not space ) only ; STEP 2 of the above algorithm\\\"\\nSolution in C:\",\"targets\":\"void reverseWords ( char * s ) { char * word_begin = NULL ; char * temp = s ; while ( * temp ) { if ( ( word_begin == NULL ) && ( * temp != ' ▁ ' ) ) { word_begin = temp ; } if ( word_begin && ( ( * ( temp + 1 ) == ' ▁ ' ) || ( * ( temp + 1 ) == ' \\\\0' ) ) ) { reverse ( word_begin , temp ) ; word_begin = NULL ; } temp ++ ; } reverse ( s , temp - 1 ) ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Average of even numbers till a given even number | Function to calculate the average of even numbers ; driver function\\\"\\nSolution in Javascript:\",\"targets\":\"function averageEven ( n ) { if ( n % 2 != 0 ) { document . write ( \\\" \\\" ) ; return - 1 ; } return ( n + 2 ) \\/ 2 ; } let n = 16 ; document . write ( averageEven ( n ) ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Primality Test | Set 5 ( Using Lucas | Function to check whether \\/ ( 2 ^ p - 1 ) is prime or not . ; generate the number ; First number of the series ; Generate the rest ( p - 2 ) terms of the series . ; now if the ( p - 1 ) th term is 0 return true else false . ; Driver Code Check whether 2 ^ p - 1 is prime or not .\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function isPrime ( $ p ) { $ checkNumber = pow ( 2 , $ p ) - 1 ; $ nextval = 4 % $ checkNumber ; for ( $ i = 1 ; $ i < $ p - 1 ; $ i ++ ) $ nextval = ( $ nextval * $ nextval - 2 ) % $ checkNumber ; return ( $ nextval == 0 ) ; } $ p = 7 ; $ checkNumber = pow ( 2 , $ p ) - 1 ; if ( isPrime ( $ p ) ) echo $ checkNumber , \\\" ▁ is ▁ Prime . \\\" ; else echo $ checkNumber , \\\" ▁ is ▁ not ▁ Prime . \\\" ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Linear Search | Java program for linear search ; run loop from 0 to right ; if search_element is found with left variable ; if search_element is found with right variable ; if element not found ; Driver code ; Function call\\\"\\nSolution in Java:\",\"targets\":\"import java . io . * ; class GFG { public static void search ( int arr [ ] , int search_Element ) { int left = 0 ; int length = arr . length ; int right = length - 1 ; int position = - 1 ; for ( left = 0 ; left <= right ; ) { if ( arr [ left ] == search_Element ) { position = left ; System . out . println ( \\\" Element ▁ found ▁ in ▁ Array ▁ at ▁ \\\" + ( position + 1 ) + \\\" ▁ Position ▁ with ▁ \\\" + ( left + 1 ) + \\\" ▁ Attempt \\\" ) ; break ; } if ( arr [ right ] == search_Element ) { position = right ; System . out . println ( \\\" Element ▁ found ▁ in ▁ Array ▁ at ▁ \\\" + ( position + 1 ) + \\\" ▁ Position ▁ with ▁ \\\" + ( length - right ) + \\\" ▁ Attempt \\\" ) ; break ; } left ++ ; right -- ; } if ( position == - 1 ) System . out . println ( \\\" Not ▁ found ▁ in ▁ Array ▁ with ▁ \\\" + left + \\\" ▁ Attempt \\\" ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int search_element = 5 ; search ( arr , search_element ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Check if all elements of a Circular Array can be made equal by increments of adjacent pairs | C ++ Program to implement the above approach ; Function to check if all array elements can be made equal ; Stores the sum of even and odd array elements ; If index is odd ; Driver Code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; bool checkEquall ( int arr [ ] , int N ) { int sumEven = 0 , sumOdd = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( i & 1 ) sumOdd += arr [ i ] ; else sumEven += arr [ i ] ; } if ( sumEven == sumOdd ) return true ; else return false ; } int main ( ) { int arr [ ] = { 2 , 7 , 3 , 5 , 7 } ; int N = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; if ( checkEquall ( arr , N ) ) cout << \\\" YES \\\" << endl ; else cout << \\\" NO \\\" << endl ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Count of indices in an array that satisfy the given condition | C # implementation of the approach ; Function to return the count of indices that satisfy the given condition ; To store the result ; To store the current maximum Initialized to 0 since there are only positive elements in the array ; i is a valid index ; Update the maximum so far ; Increment the counter ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int countIndices ( int [ ] arr , int n ) { int cnt = 0 ; int max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( max < arr [ i ] ) { max = arr [ i ] ; cnt ++ ; } } return cnt ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int n = arr . Length ; Console . WriteLine ( countIndices ( arr , n ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Queries to count Palindrome Numbers from a range whose sum of digits is a Prime Number | C # program for the above approach ; Function to check if the number N is palindrome or not ; Store the value of N ; Store the reverse of number N ; Reverse temp and store in res ; If N is the same as res , then return true ; Function to find the sum of the digits of the number N ; Stores the sum of the digits ; Add the last digit of the number N to the sum ; Remove the last digit from N ; Return the resultant sum ; Function to check if N is prime or not ; If i is 1 or 0 , then return false ; Check if i is divisible by any number in the range [ 2 , n \\/ 2 ] ; If n is divisible by i ; Function to precompute all the numbers till 10 ^ 5 that are palindromic and whose sum of digits is prime numbers ; Iterate over the range 1 to 10 ^ 5 ; If i is a palindrome number ; Stores the sum of the digits in i ; If the sum of digits in i is a prime number ; Find the prefix sum of arr [ ] ; Function to count all the numbers in the given ranges that are palindromic and the sum of digits is prime numbers ; Function Call to precompute all the numbers till 10 ^ 5 ; Traverse the given queries Q [ ] ; Print the result for each query ; Driver Code ; Function Call\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int [ ] arr = new int [ 100005 ] ; static bool isPalindrome ( int N ) { int temp = N ; int res = 0 ; while ( temp != 0 ) { int rem = temp % 10 ; res = res * 10 + rem ; temp \\/= 10 ; } if ( res == N ) { return true ; } else { return false ; } } static int sumOfDigits ( int N ) { int sum = 0 ; while ( N != 0 ) { sum += N % 10 ; N \\/= 10 ; } return sum ; } static bool isPrime ( int n ) { if ( n <= 1 ) { return false ; } for ( int i = 2 ; i <= n \\/ 2 ; ++ i ) { if ( n % i == 0 ) return false ; } return true ; } static void precompute ( ) { for ( int i = 1 ; i <= 100000 ; i ++ ) { if ( isPalindrome ( i ) ) { int sum = sumOfDigits ( i ) ; if ( isPrime ( sum ) ) arr [ i ] = 1 ; else arr [ i ] = 0 ; } else arr [ i ] = 0 ; } for ( int i = 1 ; i <= 100000 ; i ++ ) { arr [ i ] = arr [ i ] + arr [ i - 1 ] ; } } static void countNumbers ( int [ , ] Q , int N ) { precompute ( ) ; for ( int i = 0 ; i < N ; i ++ ) { Console . WriteLine ( ( arr [ Q [ i , 1 ] ] - arr [ Q [ i , 0 ] - 1 ] ) ) ; } } static public void Main ( ) { int [ , ] Q = { { 5 , 9 } , { 1 , 101 } } ; int N = Q . GetLength ( 0 ) ; countNumbers ( Q , N ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Efficient program to print all prime factors of a given number | Program to print all prime factors ; A function to print all prime factors of a given number n ; Print the number of 2 s that divide n ; n must be odd at this point . So we can skip one element ( Note i = i + 2 ) ; While i divides n , print i and divide n ; This condition is to handle the case when n is a prime number greater than 2 ; Driver program to test above function\\\"\\nSolution in C:\",\"targets\":\"# include \\n# include \\nvoid primeFactors ( int n ) { while ( n % 2 == 0 ) { printf ( \\\" % d ▁ \\\" , 2 ) ; n = n \\/ 2 ; } for ( int i = 3 ; i <= sqrt ( n ) ; i = i + 2 ) { while ( n % i == 0 ) { printf ( \\\" % d ▁ \\\" , i ) ; n = n \\/ i ; } } if ( n > 2 ) printf ( \\\" % d ▁ \\\" , n ) ; } int main ( ) { int n = 315 ; primeFactors ( n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Array with GCD of any of its subset belongs to the given array | Java implementation to generate the required array ; Function to return gcd of a and b ; Function to find gcd of array of numbers ; Function to generate the array with required constraints . ; computing GCD of the given set ; Solution exists if GCD of array is equal to the minimum element of the array ; Printing the built array ; Driver Code ; Taking in the input and initializing the set STL set in cpp has a property that it maintains the elements in sorted order , thus we do not need to sort them externally ; Calling the computing function .\\\"\\nSolution in Java:\",\"targets\":\"import java . io . * ; import java . util . * ; class GFG { static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } public static int findGCD ( ArrayList < Integer > arr , int n ) { int result = arr . get ( 0 ) ; for ( int i = 1 ; i < n ; i ++ ) result = gcd ( arr . get ( i ) , result ) ; return result ; } public static void compute ( ArrayList < Integer > arr , int n ) { ArrayList < Integer > answer = new ArrayList < Integer > ( ) ; int GCD_of_array = findGCD ( arr , n ) ; if ( GCD_of_array == arr . get ( 0 ) ) { answer . add ( arr . get ( 0 ) ) ; for ( int i = 1 ; i < n ; i ++ ) { answer . add ( arr . get ( 0 ) ) ; answer . add ( arr . get ( i ) ) ; } for ( int i = 0 ; i < answer . size ( ) ; i ++ ) System . out . print ( answer . get ( i ) + \\\" ▁ \\\" ) ; } else System . out . print ( \\\" No ▁ array ▁ \\\" + \\\" can ▁ be ▁ build \\\" ) ; } public static void main ( String args [ ] ) { int n = 3 ; Integer input [ ] = { 2 , 5 , 6 , 7 , 11 } ; HashSet < Integer > GCD = new HashSet < Integer > ( Arrays . asList ( input ) ) ; ArrayList < Integer > arr = new ArrayList < Integer > ( ) ; for ( int v : GCD ) arr . add ( v ) ; compute ( arr , n ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Print all n | n -- > value of input out -- > output array index -- > index of next digit to be filled in output array evenSum , oddSum -- > sum of even and odd digits so far ; Base case ; If number becomes n - digit ; if absolute difference between sum of even and odd digits is 1 , print the number ; If current index is odd , then add it to odd sum and recurse ; else else add to even sum and recurse ; This is mainly a wrapper over findNDigitNumsUtil . It explicitly handles leading digit and calls findNDigitNumsUtil ( ) for remaining indexes . ; output array to store n - digit numbers ; Initialize number index considered so far ; Initialize even and odd sums ; Explicitly handle first digit and call recursive function findNDigitNumsUtil for remaining indexes . Note that the first digit is considered to be present in even position . ; Driver program\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function findNDigitNumsUtil ( $ n , $ out , $ index , $ evenSum , $ oddSum ) { if ( $ index > $ n ) return ; if ( $ index == $ n ) { if ( abs ( $ evenSum - $ oddSum ) == 1 ) { echo implode ( \\\" \\\" , $ out ) . \\\" \\\" } return ; } if ( $ index & 1 ) { for ( $ i = 0 ; $ i <= 9 ; $ i ++ ) { $ out [ $ index ] = $ i + '0' ; findNDigitNumsUtil ( $ n , $ out , $ index + 1 , $ evenSum , $ oddSum + $ i ) ; } } { for ( $ i = 0 ; $ i <= 9 ; $ i ++ ) { $ out [ $ index ] = $ i + '0' ; findNDigitNumsUtil ( $ n , $ out , $ index + 1 , $ evenSum + $ i , $ oddSum ) ; } } } function findNDigitNums ( $ n ) { $ out = array_fill ( 0 , $ n + 1 , \\\" \\\" ) ; $ index = 0 ; $ evenSum = 0 ; $ oddSum = 0 ; for ( $ i = 1 ; $ i <= 9 ; $ i ++ ) { $ out [ $ index ] = $ i + '0' ; findNDigitNumsUtil ( $ n , $ out , $ index + 1 , $ evenSum + $ i , $ oddSum ) ; } } $ n = 3 ; findNDigitNums ( $ n ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"Search , insert and delete in an unsorted array | C program to implement insert operation in an unsorted array . ; Inserts a key in arr [ ] of given capacity . n is current size of arr [ ] . This function returns n + 1 if insertion is successful , else n . ; Cannot insert more elements if n is already more than or equal to capcity ; Driver Code ; Inserting key\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint insertSorted ( int arr [ ] , int n , int key , int capacity ) { if ( n >= capacity ) return n ; arr [ n ] = key ; return ( n + 1 ) ; } int main ( ) { int arr [ 20 ] = { 12 , 16 , 20 , 40 , 50 , 70 } ; int capacity = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; int n = 6 ; int i , key = 26 ; printf ( \\\" Before Insertion : \\\" for ( i = 0 ; i < n ; i ++ ) printf ( \\\" % d ▁ \\\" , arr [ i ] ) ; n = insertSorted ( arr , n , key , capacity ) ; printf ( \\\" After Insertion : \\\" for ( i = 0 ; i < n ; i ++ ) printf ( \\\" % d ▁ \\\" , arr [ i ] ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Find the original coordinates whose Manhattan distances are given | C # implementation of the approach ; Function to find the original coordinated ; Maximum of the given distances ; Sum of the given distances ; Conditions when the solution doesn 't exist ; First coordinate ; Second coordinate ; Third coordinate ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static void solve ( int d1 , int d2 , int d3 ) { int maxx = Math . Max ( d1 , Math . Max ( d2 , d3 ) ) ; int sum = ( d1 + d2 + d3 ) ; if ( 2 * maxx > sum sum % 2 == 1 ) { Console . WriteLine ( \\\" - 1\\\" ) ; return ; } int x1 = 0 , y1 = 0 ; int x2 = d1 , y2 = 0 ; int x3 = ( d1 + d2 - d3 ) \\/ 2 ; int y3 = ( d2 + d3 - d1 ) \\/ 2 ; Console . WriteLine ( \\\" ( \\\" + x1 + \\\" , ▁ \\\" + y1 + \\\" ) , ▁ ( \\\" + x2 + \\\" , ▁ \\\" + y2 + \\\" ) ▁ and ▁ ( \\\" + x3 + \\\" , ▁ \\\" + y3 + \\\" ) \\\" ) ; } static void Main ( ) { int d1 = 3 , d2 = 4 , d3 = 5 ; solve ( d1 , d2 , d3 ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Check if a String contains any index with more than K active characters | Function to check if any index contains more than K active characters ; Store the last occurrence of each character in the map . ; Stores the active characters ; Insert the character ; If the size of set exceeds K ; Remove the character from set if i is the last index of the current character ; Driver Code\\\"\\nSolution in Javascript:\",\"targets\":\"function checkString ( s , K ) { var n = s . length ; var mp = new Map ( ) ; for ( var i = 0 ; i < n ; i ++ ) { if ( mp . has ( s [ i ] ) ) { mp . set ( s [ i ] , mp . get ( s [ i ] ) + 1 ) ; } else mp . set ( s [ i ] , 1 ) ; } var cnt = 0 , f = 0 ; var st = new Set ( ) ; for ( var i = 0 ; i < n ; i ++ ) { st . add ( s [ i ] ) ; if ( st . size > K ) { f = 1 ; break ; } if ( mp . get ( s [ i ] ) == i ) st . delete ( s [ i ] ) ; } return ( f == 1 ? \\\" \\\" : \\\" \\\" ) ; } var s = \\\" \\\" ; var k = 2 ; document . write ( checkString ( s , k ) ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"Search in a row wise and column wise sorted matrix | C program to search an element in row - wise and column - wise sorted matrix ; Searches the element x in mat [ ] [ ] . If the element is found , then prints its position and returns true , otherwise prints \\\" not ▁ found \\\" and returns false ; set indexes for top right element ; if mat [ i ] [ j ] < x ; if ( i == n j == - 1 ) ; driver program to test above function\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint search ( int mat [ 4 ] [ 4 ] , int n , int x ) { if ( n == 0 ) return -1 ; int smallest = mat [ 0 ] [ 0 ] , largest = mat [ n - 1 ] [ n - 1 ] ; if ( x < smallest x > largest ) return -1 ; int i = 0 , j = n - 1 ; while ( i < n && j >= 0 ) { if ( mat [ i ] [ j ] == x ) { printf ( \\\" Found at % d , % d \\\" , i , j ) ; return 1 ; } if ( mat [ i ] [ j ] > x ) j -- ; else i ++ ; } printf ( \\\" n ▁ Element ▁ not ▁ found \\\" ) ; return 0 ; } int main ( ) { int mat [ 4 ] [ 4 ] = { { 10 , 20 , 30 , 40 } , { 15 , 25 , 35 , 45 } , { 27 , 29 , 37 , 48 } , { 32 , 33 , 39 , 50 } , } ; search ( mat , 4 , 29 ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Convert given Strings into T by replacing characters in between strings any number of times | Java program for the above approach ; Function to check if it possible to make all the strings equal to the string T ; Stores the frequency of all the strings in the array arr [ ] ; Stores the frequency of the string T ; Iterate over the characters of the string T ; Iterate in the range [ 0 , N - 1 ] ; Iterate over the characters of the string arr [ i ] ; If freqT [ i ] is 0 and freqS [ i ] is not 0 ; If freqS [ i ] is 0 and freqT [ i ] is not 0 ; If freqS [ i ] is not freqT [ i ] * N ; Otherwise , return \\\" Yes \\\" ; Driver Code\\\"\\nSolution in Java:\",\"targets\":\"public class GFG { static String checkIfPossible ( int N , String [ ] arr , String T ) { int [ ] freqS = new int [ 256 ] ; int [ ] freqT = new int [ 256 ] ; for ( char ch : T . toCharArray ( ) ) { freqT [ ch - ' a ' ] ++ ; } for ( int i = 0 ; i < N ; i ++ ) { for ( char ch : arr [ i ] . toCharArray ( ) ) { freqS [ ch - ' a ' ] ++ ; } } for ( int i = 0 ; i < 256 ; i ++ ) { if ( freqT [ i ] == 0 && freqS [ i ] != 0 ) { return \\\" No \\\" ; } else if ( freqS [ i ] == 0 && freqT [ i ] != 0 ) { return \\\" No \\\" ; } else if ( freqT [ i ] != 0 && freqS [ i ] != ( freqT [ i ] * N ) ) { return \\\" No \\\" ; } } return \\\" Yes \\\" ; } public static void main ( String [ ] args ) { String [ ] arr = { \\\" abc \\\" , \\\" abb \\\" , \\\" acc \\\" } ; String T = \\\" abc \\\" ; int N = arr . length ; System . out . println ( checkIfPossible ( N , arr , T ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Count of sticks required to represent the given string | stick [ ] stores the count of matchsticks required to represent the alphabets ; number [ ] stores the count of matchsticks required to represent the numerals ; Function that return the count of sticks required to represent the given string ; For every char of the given string ; Add the count of sticks required to represent the current character ; Driver Code ; Function Call\\\"\\nSolution in Javascript:\",\"targets\":\"var sticks = [ 6 , 7 , 4 , 6 , 5 , 4 , 6 , 5 , 2 , 4 , 4 , 3 , 6 , 6 , 6 , 5 , 7 , 6 , 5 , 3 , 5 , 4 , 6 , 4 , 3 , 4 ] var number = [ 6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 ] ; function countSticks ( str ) { var cnt = 0 ; for ( var i = 0 ; str [ i ] ; i ++ ) { var ch = str [ i ] ; if ( ch >= ' ' && ch <= ' ' ) { cnt += sticks [ ch . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ; } else { cnt += number [ ch . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ; } } return cnt ; } var str = \\\" \\\" ; document . write ( countSticks ( str ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Replace every matrix element with maximum of GCD of row or column | Python3 program to replace each each element with maximum of GCD of row or column . ; returning the greatest common divisor of two number ; Finding GCD of each row and column and replacing with each element with maximum of GCD of row or column . ; Calculating GCD of each row and each column in O ( mn ) and store in arrays . ; Replacing matrix element ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"R = 3\\nC = 4\\ndef gcd ( a , b ) :\\n\\tif ( b == 0 ) :\\n\\t\\treturn a\\n\\treturn gcd ( b , a % b )\\ndef replacematrix ( mat , n , m ) :\\n\\trgcd = [ 0 ] * R\\n\\tcgcd = [ 0 ] * C\\n\\tfor i in range ( n ) :\\n\\t\\tfor j in range ( m ) :\\n\\t\\t\\trgcd [ i ] = gcd ( rgcd [ i ] , mat [ i ] [ j ] )\\n\\t\\t\\tcgcd [ j ] = gcd ( cgcd [ j ] , mat [ i ] [ j ] )\\n\\tfor i in range ( n ) :\\n\\t\\tfor j in range ( m ) :\\n\\t\\t\\tmat [ i ] [ j ] = max ( rgcd [ i ] , cgcd [ j ] )\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tm = [ [ 1 , 2 , 3 , 3 ] , [ 4 , 5 , 6 , 6 ] , [ 7 , 8 , 9 , 9 ] ]\\n\\treplacematrix ( m , R , C )\\n\\tfor i in range ( R ) :\\n\\t\\tfor j in range ( C ) :\\n\\t\\t\\tprint ( m [ i ] [ j ] , end = \\\" ▁ \\\" )\\n\\t\\tprint ( )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Sum of products of all combination taken ( 1 to n ) at a time | to store sum of every combination ; if we have reached sufficient depth ; find the product of combination ; add the product into sum ; recursion to produce different combination ; function to print sum of products of all combination taken 1 - N at a time ; creating temporary array for storing combination ; call combination with r = i for combination taken i at a time ; displaying sum ; Driver code ; storing numbers from 1 - N in array ; calling allCombination\\\"\\nHow can the above be solved in JS?\",\"targets\":\"let sum = 0 ; function Combination ( a , combi , n , r , depth , index ) { if ( index == r ) { let product = 1 ; for ( let i = 0 ; i < r ; i ++ ) product = product * combi [ i ] ; sum += product ; return ; } for ( let i = depth ; i < n ; i ++ ) { combi [ index ] = a [ i ] ; Combination ( a , combi , n , r , i + 1 , index + 1 ) ; } } function allCombination ( a , n ) { for ( let i = 1 ; i <= n ; i ++ ) { let combi = [ ] ; Combination ( a , combi , n , i , 0 , 0 ) ; document . write ( \\\" \\\" + i + \\\" \\\" + sum + \\\" \\\" ) ; sum = 0 ; } } let n = 5 ; let a = [ ] ; for ( let i = 0 ; i < n ; i ++ ) a [ i ] = i + 1 ; allCombination ( a , n ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Maximum length palindrome that can be created with characters in range L and R | C # implementation of the approach ; Function to return the length of the longest palindrome that can be formed using the characters in the range [ l , r ] ; 0 - based indexing ; Marks if there is an odd frequency character ; Length of the longest palindrome possible from characters in range ; Traverse for all characters and count their frequencies ; Find the frequency in range 1 - r ; Exclude the frequencies in range 1 - ( l - 1 ) ; If frequency is odd , then add 1 less than the original frequency to make it even ; Else completely add if even ; If any odd frequency character is present then add 1 ; Function to pre - calculate the frequencies of the characters to reduce complexity ; Iterate and increase the count ; Create a prefix type array ; Driver code ; Pre - calculate prefix array ; Perform queries\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int N = 4 ; static int performQueries ( int l , int r , int [ , ] prefix ) { l -- ; r -- ; bool flag = false ; int count = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { int cnt = prefix [ r , i ] ; if ( l > 0 ) cnt -= prefix [ l - 1 , i ] ; if ( cnt % 2 == 1 ) { flag = true ; count += cnt - 1 ; } else count += cnt ; } if ( flag ) count += 1 ; return count ; } static void preCalculate ( string s , int [ , ] prefix ) { int n = s . Length ; for ( int i = 0 ; i < n ; i ++ ) { prefix [ i , s [ i ] - ' a ' ] ++ ; } for ( int i = 1 ; i < n ; i ++ ) { for ( int j = 0 ; j < 26 ; j ++ ) prefix [ i , j ] += prefix [ i - 1 , j ] ; } } public static void Main ( ) { string s = \\\" amim \\\" ; int [ , ] prefix = new int [ N , 26 ] ; preCalculate ( s , prefix ) ; int [ , ] queries = { { 1 , 4 } , { 3 , 4 } } ; int q = queries . Length ; for ( int i = 0 ; i < q ; i ++ ) { Console . WriteLine ( performQueries ( queries [ i , 0 ] , queries [ i , 1 ] , prefix ) ) ; } } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Lexicographically largest string possible by reversing substrings having even number of 1 s | Function to find the lexicographically maximum string by reversing substrings having even numbers of 1 s ; Store size of string ; Traverse the string ; Count the number of 1 s ; Stores the starting index ; Stores the end index ; Increment count , when 1 is encountered ; Traverse the remaining string ; Reverse the string from starting and end index ; Printing the string ; Driver Code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function lexicographicallyMax ( s ) { var n = s . length ; for ( var i = 0 ; i < n ; i ++ ) { var count = 0 ; var beg = i ; var end = i ; if ( s [ i ] == ' ' ) count ++ ; for ( var j = i + 1 ; j < n ; j ++ ) { if ( s [ j ] == ' ' ) count ++ ; if ( count % 2 == 0 && count != 0 ) { end = j ; break ; } } for ( var i = beg ; i < parseInt ( ( end + 1 ) \\/ 2 ) ; i ++ ) { let temp = s [ i ] ; s [ i ] = s [ end - i + 1 ] ; s [ end - i + 1 ] = temp ; } } document . write ( s . join ( \\\" \\\" ) + \\\" \\\" ) ; } var S = \\\" \\\" . split ( ' ' ) ; lexicographicallyMax ( S ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Efficient program to print all prime factors of a given number | Program to print all prime factors ; A function to print all prime factors of a given number n ; Print the number of 2 s that divide n ; n must be odd at this point . So we can skip one element ( Note i = i + 2 ) ; While i divides n , print i and divide n ; This condition is to handle the case whien n is a prime number greater than 2 ; Driver code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . io . * ; import java . lang . Math ; class GFG { public static void primeFactors ( int n ) { while ( n % 2 == 0 ) { System . out . print ( 2 + \\\" ▁ \\\" ) ; n \\/= 2 ; } for ( int i = 3 ; i <= Math . sqrt ( n ) ; i += 2 ) { while ( n % i == 0 ) { System . out . print ( i + \\\" ▁ \\\" ) ; n \\/= i ; } } if ( n > 2 ) System . out . print ( n ) ; } public static void main ( String [ ] args ) { int n = 315 ; primeFactors ( n ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Binomial Coefficient | DP | Python program for Optimized Dynamic Programming solution to Binomail Coefficient . This one uses the concept of pascal Triangle and less memory ; since nC0 is 1 ; Compute next row of pascal triangle using the previous row ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"def binomialCoeff ( n , k ) :\\n\\tC = [ 0 for i in xrange ( k + 1 ) ]\\n\\tC [ 0 ] = 1\\n\\tfor i in range ( 1 , n + 1 ) :\\n\\t\\tj = min ( i , k )\\n\\t\\twhile ( j > 0 ) :\\n\\t\\t\\tC [ j ] = C [ j ] + C [ j - 1 ]\\n\\t\\t\\tj -= 1\\n\\treturn C [ k ]\\nn = 5\\nk = 2\\nprint \\\" Value ▁ of ▁ C ( % d , % d ) ▁ is ▁ % d \\\" % ( n , k , binomialCoeff ( n , k ) )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Dynamic Connectivity | Set 1 ( Incremental ) | C ++ implementation of incremental connectivity ; Finding the root of node i ; union of two nodes a and b ; union based on rank ; Returns true if two nodes have same root ; Performing an operation according to query type ; type 1 query means checking if node x and y are connected or not ; If roots of x and y is same then yes is the answer ; type 2 query refers union of x and y ; If x and y have different roots then union them ; Driver function ; No . of nodes ; The following two arrays are used to implement disjoint set data structure . arr [ ] holds the parent nodes while rank array holds the rank of subset ; initializing both array and rank ; number of queries\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int root ( int arr [ ] , int i ) { while ( arr [ i ] != i ) { arr [ i ] = arr [ arr [ i ] ] ; i = arr [ i ] ; } return i ; } void weighted_union ( int arr [ ] , int rank [ ] , int a , int b ) { int root_a = root ( arr , a ) ; int root_b = root ( arr , b ) ; if ( rank [ root_a ] < rank [ root_b ] ) { arr [ root_a ] = arr [ root_b ] ; rank [ root_b ] += rank [ root_a ] ; } else { arr [ root_b ] = arr [ root_a ] ; rank [ root_a ] += rank [ root_b ] ; } } bool areSame ( int arr [ ] , int a , int b ) { return ( root ( arr , a ) == root ( arr , b ) ) ; } void query ( int type , int x , int y , int arr [ ] , int rank [ ] ) { if ( type == 1 ) { if ( areSame ( arr , x , y ) == true ) cout << \\\" Yes \\\" << endl ; else cout << \\\" No \\\" << endl ; } else if ( type == 2 ) { if ( areSame ( arr , x , y ) == false ) weighted_union ( arr , rank , x , y ) ; } } int main ( ) { int n = 7 ; int arr [ n ] , rank [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = i ; rank [ i ] = 1 ; } int q = 11 ; query ( 1 , 0 , 1 , arr , rank ) ; query ( 2 , 0 , 1 , arr , rank ) ; query ( 2 , 1 , 2 , arr , rank ) ; query ( 1 , 0 , 2 , arr , rank ) ; query ( 2 , 0 , 2 , arr , rank ) ; query ( 2 , 2 , 3 , arr , rank ) ; query ( 2 , 3 , 4 , arr , rank ) ; query ( 1 , 0 , 5 , arr , rank ) ; query ( 2 , 4 , 5 , arr , rank ) ; query ( 2 , 5 , 6 , arr , rank ) ; query ( 1 , 2 , 6 , arr , rank ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Bubble Sort | Optimized C # implementation of Bubble sort ; An optimized version of Bubble Sort ; swap arr [ j ] and arr [ j + 1 ] ; IF no two elements were swapped by inner loop , then break ; Function to print an array ; Driver method\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static void bubbleSort ( int [ ] arr , int n ) { int i , j , temp ; bool swapped ; for ( i = 0 ; i < n - 1 ; i ++ ) { swapped = false ; for ( j = 0 ; j < n - i - 1 ; j ++ ) { if ( arr [ j ] > arr [ j + 1 ] ) { temp = arr [ j ] ; arr [ j ] = arr [ j + 1 ] ; arr [ j + 1 ] = temp ; swapped = true ; } } if ( swapped == false ) break ; } } static void printArray ( int [ ] arr , int size ) { int i ; for ( i = 0 ; i < size ; i ++ ) Console . Write ( arr [ i ] + \\\" ▁ \\\" ) ; Console . WriteLine ( ) ; } public static void Main ( ) { int [ ] arr = { 64 , 34 , 25 , 12 , 22 , 11 , 90 } ; int n = arr . Length ; bubbleSort ( arr , n ) ; Console . WriteLine ( \\\" Sorted ▁ array \\\" ) ; printArray ( arr , n ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Check if a number can be represented as sum of two consecutive perfect cubes | Function to check if a number can be expressed as the sum of cubes of two consecutive numbers ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def isCubeSum ( n ) :\\n\\tfor i in range ( 1 , int ( pow ( n , 1 \\/ 3 ) ) + 1 ) :\\n\\t\\tif ( i * i * i + ( i + 1 ) * ( i + 1 ) * ( i + 1 ) == n ) :\\n\\t\\t\\treturn True ;\\n\\treturn False ;\\nif __name__ == ' _ _ main _ _ ' :\\n\\tn = 35 ;\\n\\tif ( isCubeSum ( n ) ) :\\n\\t\\tprint ( \\\" Yes \\\" ) ;\\n\\telse :\\n\\t\\tprint ( \\\" No \\\" ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"Sum of all odd length palindromic numbers within the range [ L , R ] | C program to find the sum of all odd length palindromic numbers within the given range ; Function that returns true if the given number is a palindrome ; Here we are generating a new number ( reverse_num ) * by reversing the digits of original input number ; If the original input number ( num ) is equal to * to its reverse ( reverse_num ) then its palindrome * else it is not . ; Function that returns true if the given number is of odd length ; Function to return the sum of all odd length palindromic numbers within the given range ; if number is palindrome and of odd length ; Driver code\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#include \\nbool isPalindrome ( int num ) { int reverse_num = 0 , remainder , temp ; temp = num ; while ( temp != 0 ) { remainder = temp % 10 ; reverse_num = reverse_num * 10 + remainder ; temp \\/= 10 ; } if ( reverse_num == num ) { return true ; } return false ; } bool isOddLength ( int num ) { int count = 0 ; while ( num > 0 ) { num \\/= 10 ; count ++ ; } if ( count % 2 != 0 ) { return true ; } return false ; } long sumOfAllPalindrome ( int L , int R ) { long sum = 0 ; if ( L <= R ) for ( int i = L ; i <= R ; i ++ ) { if ( isPalindrome ( i ) && isOddLength ( i ) ) { sum += i ; } } return sum ; } int main ( ) { int L = 110 , R = 1130 ; printf ( \\\" % ld \\\" , sumOfAllPalindrome ( L , R ) ) ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Generate an array of given size with equal count and sum of odd and even numbers | C # implementation to find the array containing same count of even and odd elements with equal sum of even and odd elements ; Function to find the array such that the array contains the same count of even and odd elements with equal sum of even and odd elements ; Length of array which is not divisible by 4 is unable to form such array ; Loop to find the resulted array containing the same count of even and odd elements ; Find the total sum of even elements ; Find the total sum of odd elements ; Find the difference between the total sum of even and odd elements ; The difference will be added in the last odd element ; Driver Code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static void findSolution ( int N ) { if ( N % 4 != 0 ) Console . Write ( - 1 + \\\" \\n \\\" ) ; else { int temp = 0 , sum_odd = 0 ; int sum_even = 0 ; int [ ] result = new int [ N ] ; for ( int i = 0 ; i < N ; i += 2 ) { temp += 2 ; result [ i + 1 ] = temp ; sum_even += result [ i + 1 ] ; result [ i ] = temp - 1 ; sum_odd += result [ i ] ; } int diff = sum_even - sum_odd ; result [ N - 2 ] += diff ; for ( int i = 0 ; i < N ; i ++ ) Console . Write ( result [ i ] + \\\" ▁ \\\" ) ; Console . Write ( \\\" \\n \\\" ) ; } } public static void Main ( String [ ] args ) { int N = 8 ; findSolution ( N ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Maximum sum of nodes in Binary tree such that no two are adjacent | C ++ program to find maximum sum from a subset of nodes of binary tree ; A binary tree node structure ; Utility function to create a new Binary Tree node ; Declaration of methods ; method returns maximum sum possible from subtrees rooted at grandChildrens of node ' node ' ; call for children of left child only if it is not NULL ; call for children of right child only if it is not NULL ; Utility method to return maximum sum rooted at node ' node ' ; If node is already processed then return calculated value from map ; take current node value and call for all grand children ; don 't take current node value and call for all children ; choose maximum from both above calls and store that in map ; Returns maximum sum from subset of nodes of binary tree under given constraints ; Driver code to test above methods\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; struct node { int data ; struct node * left , * right ; } ; struct node * newNode ( int data ) { struct node * temp = new struct node ; temp -> data = data ; temp -> left = temp -> right = NULL ; return temp ; } int sumOfGrandChildren ( node * node ) ; int getMaxSum ( node * node ) ; int getMaxSumUtil ( node * node , map < struct node * , int > & mp ) ; int sumOfGrandChildren ( node * node , map < struct node * , int > & mp ) { int sum = 0 ; if ( node -> left ) sum += getMaxSumUtil ( node -> left -> left , mp ) + getMaxSumUtil ( node -> left -> right , mp ) ; if ( node -> right ) sum += getMaxSumUtil ( node -> right -> left , mp ) + getMaxSumUtil ( node -> right -> right , mp ) ; return sum ; } int getMaxSumUtil ( node * node , map < struct node * , int > & mp ) { if ( node == NULL ) return 0 ; if ( mp . find ( node ) != mp . end ( ) ) return mp [ node ] ; int incl = node -> data + sumOfGrandChildren ( node , mp ) ; int excl = getMaxSumUtil ( node -> left , mp ) + getMaxSumUtil ( node -> right , mp ) ; mp [ node ] = max ( incl , excl ) ; return mp [ node ] ; } int getMaxSum ( node * node ) { if ( node == NULL ) return 0 ; map < struct node * , int > mp ; return getMaxSumUtil ( node , mp ) ; } int main ( ) { node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> right -> left = newNode ( 4 ) ; root -> right -> right = newNode ( 5 ) ; root -> left -> left = newNode ( 1 ) ; cout << getMaxSum ( root ) << endl ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Majority Element | Function to find Majority element in an array ; sentinels ; update maxCount if count of current element is greater ; if maxCount is greater than n \\/ 2 return the corresponding element ; Driver code ; Function calling\\\"\\nSolution in php:\",\"targets\":\"< ? php function findMajority ( $ arr , $ n ) { $ maxCount = 0 ; $ index = -1 ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { $ count = 0 ; for ( $ j = 0 ; $ j < $ n ; $ j ++ ) { if ( $ arr [ $ i ] == $ arr [ $ j ] ) $ count ++ ; } if ( $ count > $ maxCount ) { $ maxCount = $ count ; $ index = $ i ; } } if ( $ maxCount > $ n \\/ 2 ) echo $ arr [ $ index ] . \\\" \\n \\\" ; else echo \\\" No ▁ Majority ▁ Element \\\" . \\\" \\n \\\" ; } $ arr = array ( 1 , 1 , 2 , 1 , 3 , 5 , 1 ) ; $ n = sizeof ( $ arr ) ; findMajority ( $ arr , $ n ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Linear Search | Java program for linear search ; run loop from 0 to right ; if search_element is found with left variable ; if search_element is found with right variable ; if element not found ; Driver code ; Function call\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . io . * ; class GFG { public static void search ( int arr [ ] , int search_Element ) { int left = 0 ; int length = arr . length ; int right = length - 1 ; int position = - 1 ; for ( left = 0 ; left <= right ; ) { if ( arr [ left ] == search_Element ) { position = left ; System . out . println ( \\\" Element ▁ found ▁ in ▁ Array ▁ at ▁ \\\" + ( position + 1 ) + \\\" ▁ Position ▁ with ▁ \\\" + ( left + 1 ) + \\\" ▁ Attempt \\\" ) ; break ; } if ( arr [ right ] == search_Element ) { position = right ; System . out . println ( \\\" Element ▁ found ▁ in ▁ Array ▁ at ▁ \\\" + ( position + 1 ) + \\\" ▁ Position ▁ with ▁ \\\" + ( length - right ) + \\\" ▁ Attempt \\\" ) ; break ; } left ++ ; right -- ; } if ( position == - 1 ) System . out . println ( \\\" Not ▁ found ▁ in ▁ Array ▁ with ▁ \\\" + left + \\\" ▁ Attempt \\\" ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int search_element = 5 ; search ( arr , search_element ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Perform range sum queries on string as per given condition | Java program for the above approach ; Function to perform range sum queries on String as per the given condition ; Initialize N by String size ; Create array A [ ] for prefix sum ; Iterate till N ; Traverse the queries ; Check if if L == 1 range sum will be A [ R - 1 ] ; Condition if L > 1 range sum will be A [ R - 1 ] - A [ L - 2 ] ; Driver Code ; Given String ; Given Queries ; Function call\\\"\\nSolution in Java:\",\"targets\":\"import java . util . * ; class GFG { static class pair { int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void Range_sum_query ( String S , Vector < pair > Query ) { int N = S . length ( ) ; int [ ] A = new int [ N ] ; A [ 0 ] = S . charAt ( 0 ) - ' a ' + 1 ; for ( int i = 1 ; i < N ; i ++ ) { A [ i ] = S . charAt ( i ) - ' a ' + 1 ; A [ i ] = A [ i ] + A [ i - 1 ] ; } for ( int i = 0 ; i < Query . size ( ) ; i ++ ) { if ( Query . get ( i ) . first == 1 ) { System . out . print ( A [ ( Query . get ( i ) . second ) - 1 ] + \\\"\\n\\\"); } else { System . out . print ( A [ ( Query . get ( i ) . second ) - 1 ] - A [ ( Query . get ( i ) . first ) - 2 ] + \\\"\\n\\\"); } } } public static void main ( String [ ] args ) { String S = \\\" abcd \\\" ; Vector < pair > Query = new Vector < pair > ( ) ; Query . add ( new pair ( 2 , 4 ) ) ; Query . add ( new pair ( 1 , 3 ) ) ; Range_sum_query ( S , Query ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Minimum steps required to reach the end of a matrix | Set 2 | C # implementation of the approach ; Function to return the minimum steps required to reach the end of the matrix ; Array to determine whether a cell has been visited before ; Queue for bfs ; Initializing queue ; To store the depth of search ; BFS algorithm ; Current queue size ; Top - most element of queue ; To store index of cell for simplicity ; Base case ; If we reach ( n - 1 , n - 1 ) ; Marking the cell visited ; Pushing the adjacent cells in the queue that can be visited from the current cell ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; using System . Collections . Generic ; class GFG { static int n = 3 ; public class Pair { public int first , second ; public Pair ( int a , int b ) { first = a ; second = b ; } } static int minSteps ( int [ , ] arr ) { Boolean [ , ] v = new Boolean [ n , n ] ; Queue < Pair > q = new Queue < Pair > ( ) ; q . Enqueue ( new Pair ( 0 , 0 ) ) ; int depth = 0 ; while ( q . Count != 0 ) { int x = q . Count ; while ( x -- > 0 ) { Pair y = q . Peek ( ) ; int i = y . first , j = y . second ; q . Dequeue ( ) ; if ( v [ i , j ] ) continue ; if ( i == n - 1 && j == n - 1 ) return depth ; v [ i , j ] = true ; if ( i + arr [ i , j ] < n ) q . Enqueue ( new Pair ( i + arr [ i , j ] , j ) ) ; if ( j + arr [ i , j ] < n ) q . Enqueue ( new Pair ( i , j + arr [ i , j ] ) ) ; } depth ++ ; } return - 1 ; } public static void Main ( ) { int [ , ] arr = { { 1 , 1 , 1 } , { 1 , 1 , 1 } , { 1 , 1 , 1 } } ; Console . WriteLine ( minSteps ( arr ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Find three element from different three arrays such that a + b + c = sum | C # program to find three element from different three arrays such that a + b + c is equal to given sum ; Function to check if there is an element from each array such that sum of the three elements is equal to given sum . ; Driver Code\\\"\\nSolution in C#:\",\"targets\":\"using System ; public class GFG { static bool findTriplet ( int [ ] a1 , int [ ] a2 , int [ ] a3 , int n1 , int n2 , int n3 , int sum ) { for ( int i = 0 ; i < n1 ; i ++ ) for ( int j = 0 ; j < n2 ; j ++ ) for ( int k = 0 ; k < n3 ; k ++ ) if ( a1 [ i ] + a2 [ j ] + a3 [ k ] == sum ) return true ; return false ; } static public void Main ( ) { int [ ] a1 = { 1 , 2 , 3 , 4 , 5 } ; int [ ] a2 = { 2 , 3 , 6 , 1 , 2 } ; int [ ] a3 = { 3 , 2 , 4 , 5 , 6 } ; int sum = 9 ; int n1 = a1 . Length ; int n2 = a2 . Length ; int n3 = a3 . Length ; if ( findTriplet ( a1 , a2 , a3 , n1 , n2 , n3 , sum ) ) Console . WriteLine ( \\\" Yes \\\" ) ; else Console . WriteLine ( \\\" No \\\" ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Find a triplet ( A , B , C ) such that 3 * A + 5 * B + 7 * C is equal to N | Function to find a triplet ( A , B , C ) such that 3 * A + 5 * B + 7 * C is N ; Iterate over the range [ 0 , N7 ] ; Iterate over the range [ 0 , N5 ] ; Find the value of A ; If A is greater than or equal to 0 and divisible by 3 ; Otherwise , print - 1 ; Driver Code\\\"\\nSolution in Javascript:\",\"targets\":\"function CalculateValues ( N ) { var A = 0 , B = 0 , C = 0 ; for ( C = 0 ; C < N \\/ 7 ; C ++ ) { for ( B = 0 ; B < N \\/ 5 ; B ++ ) { var A = N - 7 * C - 5 * B ; if ( A >= 0 && A % 3 == 0 ) { document . write ( \\\" \\\" + A \\/ 3 + \\\" \\\" + B + \\\" \\\" + C ) ; return ; } } } document . write ( - 1 ) ; } var N = 19 ; CalculateValues ( 19 ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Decode the string encoded with the given algorithm | Java implementation of the approach ; Function to decode and print the original String ; To store the decoded String ; Getting the mid element ; Storing the first element of the String at the median position ; If the length is even then store the second element also ; k represents the number of characters that are already stored in the c [ ] ; If String length is odd ; If it is even ; Print the decoded String ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"class GFG { static void decodeStr ( String str , int len ) { char [ ] c = new char [ len ] ; int med , pos = 1 , k ; if ( len % 2 == 1 ) med = len \\/ 2 ; else med = len \\/ 2 - 1 ; c [ med ] = str . charAt ( 0 ) ; if ( len % 2 == 0 ) c [ med + 1 ] = str . charAt ( 1 ) ; if ( len % 2 == 1 ) k = 1 ; else k = 2 ; for ( int i = k ; i < len ; i += 2 ) { c [ med - pos ] = str . charAt ( i ) ; if ( len % 2 == 1 ) c [ med + pos ] = str . charAt ( i + 1 ) ; else c [ med + pos + 1 ] = str . charAt ( i + 1 ) ; pos ++ ; } for ( int i = 0 ; i < len ; i ++ ) System . out . print ( c [ i ] ) ; } public static void main ( String [ ] args ) { String str = \\\" ofrsgkeeeekgs \\\" ; int len = str . length ( ) ; decodeStr ( str , len ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Find the number of cells in the table contains X | CPP program to find number of cells in the table contains X ; Function to find number of cells in the table contains X ; Driver code ; Function call\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int Cells ( int n , int x ) { int ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) if ( x % i == 0 && x \\/ i <= n ) ans ++ ; return ans ; } int main ( ) { int n = 6 , x = 12 ; cout << Cells ( n , x ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Count of Octal numbers upto N digits | C ++ program to find the count of natural octal numbers upto N digits ; Function to return the count of natural octal numbers upto N digits ; Loop to iterate from 1 to N and calculating number of octal numbers for every ' i ' th digit . ; Driver code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int count ( int N ) { int sum = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { sum += 7 * pow ( 8 , i - 1 ) ; } return sum ; } int main ( ) { int N = 4 ; cout << count ( N ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Count of N | C program to implement the above approach ; Function to find maximum between two numbers ; Function to find minimum between two numbers ; Function to return the count of such numbers ; For 1 - digit numbers , the count is 10 irrespective of K ; dp [ j ] stores the number of such i - digit numbers ending with j ; Stores the results of length i ; Initialize count for 1 - digit numbers ; Compute values for count of digits greater than 1 ; Find the range of allowed numbers if last digit is j ; Perform Range update ; Prefix sum to find actual count of i - digit numbers ending with j ; Update dp [ ] ; Stores the final answer ; Return the final answer ; Driver Code\\\"\\nSolution in C:\",\"targets\":\"#include \\nint max ( int num1 , int num2 ) { return ( num1 > num2 ) ? num1 : num2 ; } int min ( int num1 , int num2 ) { return ( num1 > num2 ) ? num2 : num1 ; } int getCount ( int n , int k ) { if ( n == 1 ) return 10 ; int dp [ 11 ] = { 0 } ; int next [ 11 ] = { 0 } ; for ( int i = 1 ; i <= 9 ; i ++ ) dp [ i ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= 9 ; j ++ ) { int l = max ( 0 , ( j - k ) ) ; int r = min ( 9 , ( j + k ) ) ; next [ l ] += dp [ j ] ; next [ r + 1 ] -= dp [ j ] ; } for ( int j = 1 ; j <= 9 ; j ++ ) next [ j ] += next [ j - 1 ] ; for ( int j = 0 ; j < 10 ; j ++ ) { dp [ j ] = next [ j ] ; next [ j ] = 0 ; } } int count = 0 ; for ( int i = 0 ; i <= 9 ; i ++ ) count += dp [ i ] ; return count ; } int main ( ) { int n = 2 , k = 1 ; printf ( \\\" % d \\\" , getCount ( n , k ) ) ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Encrypt string with product of number of vowels and consonants in substring of size k | Java Program to Encrypt String with product of number of vowels and consonants in every substring of size k ; isVowel ( ) is a function that returns true for a vowel and false otherwise . ; function to Encrypt the dtring ; for each substring ; substring of size k ; counting number of vowels and consonants ; append product to answer . ; Driven Program\\\"\\nSolution in Java:\",\"targets\":\"class GFG { static boolean isVowel ( char c ) { return ( c == ' a ' c == ' e ' c == ' i ' c == ' o ' c == ' u ' ) ; } static String encryptString ( String s , int n , int k ) { int countVowels = 0 ; int countConsonants = 0 ; String ans = \\\" \\\" ; for ( int l = 0 ; l <= n - k ; l ++ ) { countVowels = 0 ; countConsonants = 0 ; for ( int r = l ; r <= l + k - 1 ; r ++ ) { if ( isVowel ( s . charAt ( r ) ) == true ) { countVowels ++ ; } else { countConsonants ++ ; } } ans += String . valueOf ( countVowels * countConsonants ) ; } return ans ; } static public void main ( String [ ] args ) { String s = \\\" hello \\\" ; int n = s . length ( ) ; int k = 2 ; System . out . println ( encryptString ( s , n , k ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"Recursive function to check if a string is palindrome | A recursive C program to check whether a given number is palindrome or not ; A recursive function that check a str [ s . . e ] is palindrome or not . ; If there is only one character ; If first and last characters do not match ; If there are more than two characters , check if middle substring is also palindrome or not . ; An empty string is considered as palindrome ; Driver Code\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#include \\n#include \\nbool isPalRec ( char str [ ] , int s , int e ) { if ( s == e ) return true ; if ( str [ s ] != str [ e ] ) return false ; if ( s < e + 1 ) return isPalRec ( str , s + 1 , e - 1 ) ; return true ; } bool isPalindrome ( char str [ ] ) { int n = strlen ( str ) ; if ( n == 0 ) return true ; return isPalRec ( str , 0 , n - 1 ) ; } int main ( ) { char str [ ] = \\\" geeg \\\" ; if ( isPalindrome ( str ) ) printf ( \\\" Yes \\\" ) ; else printf ( \\\" No \\\" ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Lexicographically smallest string with given string as prefix | C ++ program for the above approach ; Function to find the whether the string temp starts with str or not ; Base Case ; Check for the corresponding characters in temp & str ; Function to find lexicographic smallest string consisting of the string str as prefix ; Sort the given array string arr [ ] ; If the i - th string contains given string as a prefix , then print the result ; If no string exists then return \\\" - 1\\\" ; Driver Code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; bool is_prefix ( string temp , string str ) { if ( temp . length ( ) < str . length ( ) ) return 0 ; else { for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str [ i ] != temp [ i ] ) return 0 ; } return 1 ; } } string lexicographicallyString ( string input [ ] , int n , string str ) { sort ( input , input + n ) ; for ( int i = 0 ; i < n ; i ++ ) { string temp = input [ i ] ; if ( is_prefix ( temp , str ) ) { return temp ; } } return \\\" - 1\\\" ; } int main ( ) { string arr [ ] = { \\\" apple \\\" , \\\" appe \\\" , \\\" apl \\\" , \\\" aapl \\\" , \\\" appax \\\" } ; string S = \\\" app \\\" ; int N = 5 ; cout << lexicographicallyString ( arr , N , S ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Find k | A simple inorder traversal based C ++ program to find k - th smallest element in a BST . ; A BST node ; Recursive function to insert an key into BST ; If a node is inserted in left subtree , then lCount of this node is increased . For simplicity , we are assuming that all keys ( tried to be inserted ) are distinct . ; Function to find k 'th largest element in BST Here count denotes the number of nodes processed so far ; base case ; else search in right subtree ; main function\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; struct Node { int data ; Node * left , * right ; int lCount ; Node ( int x ) { data = x ; left = right = NULL ; lCount = 0 ; } } ; Node * insert ( Node * root , int x ) { if ( root == NULL ) return new Node ( x ) ; if ( x < root -> data ) { root -> left = insert ( root -> left , x ) ; root -> lCount ++ ; } else if ( x > root -> data ) root -> right = insert ( root -> right , x ) ; return root ; } Node * kthSmallest ( Node * root , int k ) { if ( root == NULL ) return NULL ; int count = root -> lCount + 1 ; if ( count == k ) return root ; if ( count > k ) return kthSmallest ( root -> left , k ) ; return kthSmallest ( root -> right , k - count ) ; } int main ( ) { Node * root = NULL ; int keys [ ] = { 20 , 8 , 22 , 4 , 12 , 10 , 14 } ; for ( int x : keys ) root = insert ( root , x ) ; int k = 4 ; Node * res = kthSmallest ( root , k ) ; if ( res == NULL ) cout << \\\" There ▁ are ▁ less ▁ than ▁ k ▁ nodes ▁ in ▁ the ▁ BST \\\" ; else cout << \\\" K - th ▁ Smallest ▁ Element ▁ is ▁ \\\" << res -> data ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Minimum cost to sort an Array such that swapping X and Y costs XY | Java program to implement the above approach ; Function returns the minimum cost to sort the given array ; Create array of pairs in which 1 st element is the array element and 2 nd element is index of first ; Initialize the total cost ; Sort the array with respect to array value ; Initialize the overall minimum which is the 1 st element ; To keep track of visited elements create a visited array & initialize all elements as not visited ; Iterate over every element of the array ; If the element is visited or in the sorted position , and check for next element ; Create a vector which stores all elements of a cycle ; It covers all the elements of a cycle ; If cycle is found then the swapping is required ; Initialize local minimum with 1 st element of the vector as it contains the smallest element in the beginning ; Stores the cost with using only local minimum value . ; Stores the cost of using both local minimum and overall minimum ; Update the result2 ; Store the minimum of the two result to total cost ; Return the minimum cost ; Driver code ; Given array arr [ ] ; Function call\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { static int minCost ( int arr [ ] , int n ) { int [ ] [ ] sorted = new int [ n ] [ 2 ] ; int total_cost = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sorted [ i ] [ 0 ] = arr [ i ] ; sorted [ i ] [ 1 ] = i ; } Arrays . sort ( sorted , ( a , b ) -> a [ 0 ] - b [ 0 ] ) ; int overall_minimum = sorted [ 0 ] [ 0 ] ; boolean [ ] vis = new boolean [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( vis [ i ] && sorted [ i ] [ 1 ] == i ) continue ; ArrayList < Integer > v = new ArrayList < > ( ) ; int j = i ; while ( ! vis [ j ] ) { vis [ j ] = true ; v . add ( sorted [ j ] [ 0 ] ) ; j = sorted [ j ] [ 1 ] ; } if ( v . size ( ) > 0 ) { int local_minimum = v . get ( 0 ) , result1 = 0 , result2 = 0 ; for ( int k = 1 ; k < v . size ( ) ; k ++ ) result1 += ( local_minimum * v . get ( k ) ) ; for ( int k = 0 ; k < v . size ( ) ; k ++ ) result2 += ( overall_minimum * v . get ( k ) ) ; result2 += ( overall_minimum * local_minimum ) ; total_cost += Math . min ( result1 , result2 ) ; } } return total_cost ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 8 , 9 , 7 , 6 } ; int n = arr . length ; System . out . print ( minCost ( arr , n ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Length of the longest valid substring | Java program to implement the above approach ; Function to return the length of the longest valid substring ; Variables for left and right counter maxlength to store the maximum length found so far ; Iterating the string from left to right ; If \\\" ( \\\" is encountered , then left counter is incremented else right counter is incremented ; Whenever left is equal to right , it signifies that the subsequence is valid and ; Reseting the counters when the subsequence becomes invalid ; Iterating the string from right to left ; If \\\" ( \\\" is encountered , then left counter is incremented else right counter is incremented ; Whenever left is equal to right , it signifies that the subsequence is valid and ; Reseting the counters when the subsequence becomes invalid ; Driver code ; Function call\\\"\\nSolution in Java:\",\"targets\":\"import java . util . Scanner ; import java . util . Arrays ; class GFG { public static int solve ( String s , int n ) { int left = 0 , right = 0 ; int maxlength = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == ' ( ' ) left ++ ; else right ++ ; if ( left == right ) maxlength = Math . max ( maxlength , 2 * right ) ; else if ( right > left ) left = right = 0 ; } left = right = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( s . charAt ( i ) == ' ( ' ) left ++ ; else right ++ ; if ( left == right ) maxlength = Math . max ( maxlength , 2 * left ) ; else if ( left > right ) left = right = 0 ; } return maxlength ; } public static void main ( String args [ ] ) { System . out . print ( solve ( \\\" ( ( ( ) ( ) ( ) ( ) ( ( ( ( ) ) \\\" , 16 ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Highest power of 2 less than or equal to given number | Javascript program to find highest power of 2 smaller than or equal to n . ; Driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function highestPowerof2 ( n ) { let p = parseInt ( Math . log ( n ) \\/ Math . log ( 2 ) , 10 ) ; return Math . pow ( 2 , p ) ; } let n = 10 ; document . write ( highestPowerof2 ( n ) ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Check if at least half array is reducible to zero by performing some operations | C ++ program to find whether half - array reducible to 0 ; Function to print the desired result after computation ; Driver Code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; void isHalfReducible ( int arr [ ] , int n , int m ) { int frequencyHash [ m + 1 ] ; int i ; memset ( frequencyHash , 0 , sizeof ( frequencyHash ) ) ; for ( i = 0 ; i < n ; i ++ ) { frequencyHash [ arr [ i ] % ( m + 1 ) ] ++ ; } for ( i = 0 ; i <= m ; i ++ ) { if ( frequencyHash [ i ] >= n \\/ 2 ) break ; } if ( i <= m ) cout << \\\" Yes \\\" << endl ; else cout << \\\" No \\\" << endl ; } int main ( ) { int arr [ ] = { 8 , 16 , 32 , 3 , 12 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; int m = 7 ; isHalfReducible ( arr , n , m ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Find the number of pairs such that their gcd is equals to 1 | C # program to find the number of pairs such that gcd equals to 1 ; Function to calculate least prime factor of each number ; If it is a prime number ; For all multiples which are not visited yet . ; Function to find the value of Mobius function for all the numbers from 1 to n ; If number is one ; If number has a squared prime factor ; Multiply - 1 with the previous number ; Function to find the number of pairs such that gcd equals to 1 ; To store maximum number ; To store frequency of each number ; Find frequency and maximum number ; To store number of pairs with gcd equals to 1 ; Traverse through the all possible elements ; Return the number of pairs ; Driver code ; Function call\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static int N = 100050 ; static int [ ] lpf = new int [ N ] ; static int [ ] mobius = new int [ N ] ; static void least_prime_factor ( ) { for ( int i = 2 ; i < N ; i ++ ) if ( lpf [ i ] == 0 ) for ( int j = i ; j < N ; j += i ) if ( lpf [ j ] == 0 ) lpf [ j ] = i ; } static void Mobius ( ) { for ( int i = 1 ; i < N ; i ++ ) { if ( i == 1 ) mobius [ i ] = 1 ; else { if ( lpf [ i \\/ lpf [ i ] ] == lpf [ i ] ) mobius [ i ] = 0 ; else mobius [ i ] = - 1 * mobius [ i \\/ lpf [ i ] ] ; } } } static int gcd_pairs ( int [ ] a , int n ) { int maxi = 0 ; int [ ] fre = new int [ N ] ; for ( int i = 0 ; i < n ; i ++ ) { fre [ a [ i ] ] ++ ; maxi = Math . Max ( a [ i ] , maxi ) ; } least_prime_factor ( ) ; Mobius ( ) ; int ans = 0 ; for ( int i = 1 ; i <= maxi ; i ++ ) { if ( mobius [ i ] == 0 ) continue ; int temp = 0 ; for ( int j = i ; j <= maxi ; j += i ) temp += fre [ j ] ; ans += temp * ( temp - 1 ) \\/ 2 * mobius [ i ] ; } return ans ; } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 2 , 3 , 4 , 5 , 6 } ; int n = a . Length ; Console . Write ( gcd_pairs ( a , n ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Minimum substring removals required to make all remaining characters of a string same | ''Python3 program to implement the above approach ; ''Function to count minimum operations required to make all characters equal by repeatedly removing substring ; '' Remove consecutive duplicate characters from str ; '' Stores length of the string ; '' Stores frequency of each distinct characters of the string str ; '' Iterate over all the characters of the string str ; '' Update frequency of str[i] ; '' Decrementing the frequency of the string str[0] ; '' Decrementing the frequency of the ord(string ord(str[N - 1] ; '' Stores the required count ; '' Iterate over all characters of the string str ; '' Update ans ; ''Driver Code ; '' Given string\\\"\\nSolution in Python:\",\"targets\":\"import re , sys\\ndef minOperationNeeded ( s ) :\\n\\td = { }\\n\\tstr = re . sub ( r \\\" ( . ) \\\\1 ▁ + ▁ \\\" , ' ' , s )\\n\\tN = len ( str )\\n\\tres = [ 0 for i in range ( 256 ) ]\\n\\tfor i in range ( N ) :\\n\\t\\tres [ ord ( str [ i ] ) ] += 1\\n\\tres [ ord ( str [ 0 ] ) ] -= 1\\n\\tres [ ord ( str [ N - 1 ] ) ] -= 1\\n\\tans = sys . maxsize\\n\\tfor i in range ( N ) :\\n\\t\\tans = min ( ans , res [ ord ( str [ i ] ) ] )\\n\\tprint ( ( ans + 1 ) )\\nif __name__ == ' _ _ main _ _ ' :\\n\\tstr = \\\" ABCDABCDABCDA \\\"\\n\\tminOperationNeeded ( str )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Remove all characters other than alphabets from string | Java program to remove all the characters other then alphabets ; function to remove characters and print new string ; Store only valid characters ; driver code\\\"\\nSolution in Java:\",\"targets\":\"class GFG { static void removeSpecialCharacter ( String str ) { char [ ] s = str . toCharArray ( ) ; int j = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( ( s [ i ] >= ' A ' && s [ i ] <= ' Z ' ) || ( s [ i ] >= ' a ' && s [ i ] <= ' z ' ) ) { s [ j ] = s [ i ] ; j ++ ; } } System . out . println ( String . valueOf ( s ) . substring ( 0 , j ) ) ; } public static void main ( String [ ] args ) { String s = \\\" $ Gee * k ; s . . fo , ▁ r ' Ge ^ eks ? \\\" ; removeSpecialCharacter ( s ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Number of ways to reach the end of matrix with non | C # implementation of the approach ; 3d array to store states of dp ; Array to determine whether a state has been solved before ; Function to return the count of required paths ; Base cases ; If a state has been solved before it won 't be evaluated again ; Recurrence relation ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static int n = 3 ; static int maxV = 20 ; static int [ , , ] dp = new int [ n , n , maxV ] ; static int [ , , ] v = new int [ n , n , maxV ] ; static int countWays ( int i , int j , int x , int [ , ] arr ) { if ( i == n j == n ) { return 0 ; } x = ( x & arr [ i , j ] ) ; if ( x == 0 ) { return 0 ; } if ( i == n - 1 && j == n - 1 ) { return 1 ; } if ( v [ i , j , x ] == 1 ) { return dp [ i , j , x ] ; } v [ i , j , x ] = 1 ; dp [ i , j , x ] = countWays ( i + 1 , j , x , arr ) + countWays ( i , j + 1 , x , arr ) ; return dp [ i , j , x ] ; } public static void Main ( ) { int [ , ] arr = { { 1 , 2 , 1 } , { 1 , 1 , 0 } , { 2 , 1 , 1 } } ; Console . WriteLine ( countWays ( 0 , 0 , arr [ 0 , 0 ] , arr ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Construct a frequency array of digits of the values obtained from x ^ 1 , x ^ 2 , ... ... . . , x ^ n | Function that traverses digits in a number and modifies frequency count array ; Array to keep count of digits ; Traversing through x ^ 1 to x ^ n ; For power function , both its parameters are to be in double ; calling countDigits function on x ^ i ; Printing count of digits 0 - 9 ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function countDigits ( $ val , & $ arr ) { while ( $ val > 0 ) { $ digit = $ val % 10 ; $ arr [ ( int ) ( $ digit ) ] += 1 ; $ val = ( int ) ( $ val \\/ 10 ) ; } return ; } function countFrequency ( $ x , $ n ) { $ freq_count = array_fill ( 0 , 10 , 0 ) ; for ( $ i = 1 ; $ i < $ n + 1 ; $ i ++ ) { $ val = pow ( $ x , $ i ) ; countDigits ( $ val , $ freq_count ) ; } for ( $ i = 0 ; $ i < 10 ; $ i ++ ) { echo $ freq_count [ $ i ] . \\\" \\\" ; } } $ x = 15 ; $ n = 3 ; countFrequency ( $ x , $ n ) ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Maximize sum by choosing elements from different section of a matrix | Python3 program for the above approach ; Function to find the maximum value ; Dp table ; Fill the dp in bottom up manner ; Maximum of the three sections ; Maximum of the first section ; Maximum of the second section ; Maximum of the third section ; If we choose element from section 1 , we cannot have selection from same section in adjacent rows ; Print the maximum sum ; Driver code\\\"\\nSolution in Python:\",\"targets\":\"import numpy as np\\nn = 6 ; m = 6 ;\\ndef maxSum ( arr ) :\\n\\tdp = np . zeros ( ( n + 1 , 3 ) ) ;\\n\\tfor i in range ( n ) :\\n\\t\\tm1 = 0 ; m2 = 0 ; m3 = 0 ;\\n\\t\\tfor j in range ( m ) :\\n\\t\\t\\tif ( ( j \\/\\/ ( m \\/\\/ 3 ) ) == 0 ) :\\n\\t\\t\\t\\tm1 = max ( m1 , arr [ i ] [ j ] ) ;\\n\\t\\t\\telif ( ( j \\/\\/ ( m \\/\\/ 3 ) ) == 1 ) :\\n\\t\\t\\t\\tm2 = max ( m2 , arr [ i ] [ j ] ) ;\\n\\t\\t\\telif ( ( j \\/\\/ ( m \\/\\/ 3 ) ) == 2 ) :\\n\\t\\t\\t\\tm3 = max ( m3 , arr [ i ] [ j ] ) ;\\n\\t\\tdp [ i + 1 ] [ 0 ] = max ( dp [ i ] [ 1 ] , dp [ i ] [ 2 ] ) + m1 ;\\n\\t\\tdp [ i + 1 ] [ 1 ] = max ( dp [ i ] [ 0 ] , dp [ i ] [ 2 ] ) + m2 ;\\n\\t\\tdp [ i + 1 ] [ 2 ] = max ( dp [ i ] [ 1 ] , dp [ i ] [ 0 ] ) + m3 ;\\n\\tprint ( max ( max ( dp [ n ] [ 0 ] , dp [ n ] [ 1 ] ) , dp [ n ] [ 2 ] ) ) ;\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tarr = [ [ 1 , 3 , 5 , 2 , 4 , 6 ] , [ 6 , 4 , 5 , 1 , 3 , 2 ] , [ 1 , 3 , 5 , 2 , 4 , 6 ] , [ 6 , 4 , 5 , 1 , 3 , 2 ] , [ 6 , 4 , 5 , 1 , 3 , 2 ] , [ 1 , 3 , 5 , 2 , 4 , 6 ] ] ;\\n\\tmaxSum ( arr ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Interquartile Range ( IQR ) | Java program to find IQR of a data set ; Function to give index of the median ; Function to calculate IQR ; Index of median of entire data ; Median of first half ; Median of second half ; IQR calculation ; Driver Code\\\"\\nSolution in Java:\",\"targets\":\"import java . io . * ; import java . util . * ; class GFG { static int median ( int a [ ] , int l , int r ) { int n = r - l + 1 ; n = ( n + 1 ) \\/ 2 - 1 ; return n + l ; } static int IQR ( int [ ] a , int n ) { Arrays . sort ( a ) ; int mid_index = median ( a , 0 , n ) ; int Q1 = a [ median ( a , 0 , mid_index ) ] ; int Q3 = a [ mid_index + median ( a , mid_index + 1 , n ) ] ; return ( Q3 - Q1 ) ; } public static void main ( String [ ] args ) { int [ ] a = { 1 , 19 , 7 , 6 , 5 , 9 , 12 , 27 , 18 , 2 , 15 } ; int n = a . length ; System . out . println ( IQR ( a , n ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Program to find whether a no is power of two | C # program for above approach ; Function which checks whether a number is a power of 2 ; Base cases '1' is the only odd number which is a power of 2 ( 2 ^ 0 ) ; All other odd numbers are not powers of 2 ; Recursive function call ; Driver code ; True ; False\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static bool powerOf2 ( int n ) { if ( n == 1 ) return true ; else if ( n % 2 != 0 n == 0 ) return false ; return powerOf2 ( n \\/ 2 ) ; } static void Main ( ) { int n = 64 ; int m = 12 ; if ( powerOf2 ( n ) ) { Console . Write ( \\\" True \\\" + \\\" \\n \\\" ) ; } else { Console . Write ( \\\" False \\\" + \\\" \\n \\\" ) ; } if ( powerOf2 ( m ) ) { Console . Write ( \\\" True \\\" ) ; } else { Console . Write ( \\\" False \\\" ) ; } } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Modify string by removing vowels in between two consonants | Java program to remove all Vowels in between two consonants from the string ; Function to check if the character x is a vowel or not ; Returns the updated string formed after removing all the Sandwiched Vowels from the given string ; string to store the Updated String after removing the Sandwiched Vowels ; traverse the string from left to right ; if the current character is the first or the last character of the string then , this needs to be appended to the updatedString , since the corner alphabet irrespective of it being a vowel or a consonant , is never ' Sandwiched ' ; Check if the current character of the string is a vowel and both the previous and the next characters are consonants , if so then this is a sandwiched vowel , thus is ignored and not appended to the updated string ; if this character is not a sandwiched Vowel append it to the updated String ; Driver Code ; Remove all the Sandwitched Vowels\\\"\\nSolution in Java:\",\"targets\":\"import java . io . * ; import java . util . * ; import java . lang . * ; class GFG { static boolean isVowel ( char x ) { if ( x == ' a ' x == ' e ' x == ' i ' x == ' o ' x == ' u ' ) return true ; else return false ; } static String updateSandwichedVowels ( String a ) { int n = a . length ( ) ; String updatedString = \\\" \\\" ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == 0 i == n - 1 ) { updatedString += a . charAt ( i ) ; continue ; } if ( isVowel ( a . charAt ( i ) ) == true && isVowel ( a . charAt ( i - 1 ) ) == false && isVowel ( a . charAt ( i + 1 ) ) == false ) { continue ; } updatedString += a . charAt ( i ) ; } return updatedString ; } public static void main ( String [ ] args ) { String str = \\\" geeksforgeeks \\\" ; String updatedString = updateSandwichedVowels ( str ) ; System . out . print ( updatedString ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Decode an Encoded Base 64 String to ASCII String | C Program to decode a base64 Encoded string back to ASCII string ; char_set = \\\" ABCDEFGHIJKLMNOPQRSTUVWXYZ ▁ abcdefghijklmnopqrstuvwxyz0123456789 + \\/ \\\" ; stores the bitstream . ; count_bits stores current number of bits in num . ; selects 4 characters from encoded string at a time . find the position of each encoded character in char_set and stores in num . ; make space for 6 bits . ; encoded [ i + j ] = ' E ' , ' E ' - ' A ' = 5 ' E ' has 5 th position in char_set . ; encoded [ i + j ] = ' e ' , ' e ' - ' a ' = 5 , 5 + 26 = 31 , ' e ' has 31 st position in char_set . ; encoded [ i + j ] = '8' , '8' - '0' = 8 8 + 52 = 60 , '8' has 60 th position in char_set . ; ' + ' occurs in 62 nd position in char_set . ; ' \\/ ' occurs in 63 rd position in char_set . ; ( str [ i + j ] == ' = ' ) remove 2 bits to delete appended bits during encoding . ; 255 in binary is 11111111 ; Driver function ; Do not count last NULL character .\\\"\\nSolution in C:\",\"targets\":\"#include \\n#include \\n#define SIZE 100\\nchar * base64Decoder ( char encoded [ ] , int len_str ) { char * decoded_string ; decoded_string = ( char * ) malloc ( sizeof ( char ) * SIZE ) ; int i , j , k = 0 ; int num = 0 ; int count_bits = 0 ; for ( i = 0 ; i < len_str ; i += 4 ) { num = 0 , count_bits = 0 ; for ( j = 0 ; j < 4 ; j ++ ) { if ( encoded [ i + j ] != ' = ' ) { num = num << 6 ; count_bits += 6 ; } if ( encoded [ i + j ] >= ' A ' && encoded [ i + j ] <= ' Z ' ) num = num | ( encoded [ i + j ] - ' A ' ) ; else if ( encoded [ i + j ] >= ' a ' && encoded [ i + j ] <= ' z ' ) num = num | ( encoded [ i + j ] - ' a ' + 26 ) ; else if ( encoded [ i + j ] >= '0' && encoded [ i + j ] <= '9' ) num = num | ( encoded [ i + j ] - '0' + 52 ) ; else if ( encoded [ i + j ] == ' + ' ) num = num | 62 ; else if ( encoded [ i + j ] == ' \\/ ' ) num = num | 63 ; else { num = num >> 2 ; count_bits -= 2 ; } } while ( count_bits != 0 ) { count_bits -= 8 ; decoded_string [ k ++ ] = ( num >> count_bits ) & 255 ; } } decoded_string [ k ] = ' \\\\0' ; return decoded_string ; } int main ( ) { char encoded_string [ ] = \\\" TUVOT04 = \\\" ; int len_str = sizeof ( encoded_string ) \\/ sizeof ( encoded_string [ 0 ] ) ; len_str -= 1 ; printf ( \\\" Encoded ▁ string ▁ : ▁ % s \\n \\\" , encoded_string ) ; printf ( \\\" Decoded _ string ▁ : ▁ % s \\n \\\" , base64Decoder ( encoded_string , len_str ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Print array after it is right rotated K times | Java Implementation of Right Rotation of an Array K number of times ; Function to rightRotate array ; If rotation is greater than size of array ; Printing rightmost kth elements ; Prints array after ' k ' elements ; Driver program\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; import java . lang . * ; import java . io . * ; class Array_Rotation { static void RightRotate ( int a [ ] , int n , int k ) { k = k % n ; for ( int i = 0 ; i < n ; i ++ ) { if ( i < k ) { System . out . print ( a [ n + i - k ] + \\\" ▁ \\\" ) ; } else { System . out . print ( a [ i - k ] + \\\" ▁ \\\" ) ; } } System . out . println ( ) ; } public static void main ( String args [ ] ) { int Array [ ] = { 1 , 2 , 3 , 4 , 5 } ; int N = Array . length ; int K = 2 ; RightRotate ( Array , N , K ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Reverse actual bits of the given number | Java implementation to reverse bits of a number ; function to reverse bits of a number ; traversing bits of ' n ' from the right ; bitwise left shift ' rev ' by 1 ; if current bit is '1' ; bitwise right shift ' n ' by 1 ; required number ; Driver code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"class GFG { public static int reverseBits ( int n ) { int rev = 0 ; while ( n > 0 ) { rev <<= 1 ; if ( ( int ) ( n & 1 ) == 1 ) rev ^= 1 ; n >>= 1 ; } return rev ; } public static void main ( String [ ] args ) { int n = 11 ; System . out . println ( reverseBits ( n ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Find the maximum repeating number in O ( n ) time and O ( 1 ) extra space | Returns maximum repeating element in arr [ 0. . n - 1 ] . The array elements are in range from 0 to k - 1 ; Iterate though input array , for every element arr [ i ] , increment arr [ arr [ i ] % k ] by k ; Find index of the maximum repeating element ; Return index of the maximum element ; Driver program to test above function\\\"\\nSolution in Python:\",\"targets\":\"def maxRepeating ( arr , n , k ) :\\n\\tfor i in range ( 0 , n ) :\\n\\t\\tarr [ arr [ i ] % k ] += k\\n\\tmax = arr [ 0 ]\\n\\tresult = 0\\n\\tfor i in range ( 1 , n ) :\\n\\t\\tif arr [ i ] > max :\\n\\t\\t\\tmax = arr [ i ]\\n\\t\\t\\tresult = i\\n\\treturn result\\narr = [ 2 , 3 , 3 , 5 , 3 , 4 , 1 , 7 ]\\nn = len ( arr )\\nk = 8\\nprint ( \\\" The ▁ maximum ▁ repeating ▁ number ▁ is \\\" , maxRepeating ( arr , n , k ) )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Number of ways to remove a sub | C # program to count number of ways of removing a substring from a string such that all remaining characters are equal ; Function to return the number of ways of removing a sub - string from s such that all the remaining characters are same ; To store the count of prefix and suffix ; Loop to count prefix ; Loop to count suffix ; First and last characters of the string are same ; Otherwise ; Driver Code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static int no_of_ways ( string s ) { int n = s . Length ; int count_left = 0 , count_right = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( s [ i ] == s [ 0 ] ) { ++ count_left ; } else break ; } for ( int i = n - 1 ; i >= 0 ; -- i ) { if ( s [ i ] == s [ n - 1 ] ) { ++ count_right ; } else break ; } if ( s [ 0 ] == s [ n - 1 ] ) return ( ( count_left + 1 ) * ( count_right + 1 ) ) ; else return ( count_left + count_right + 1 ) ; } public static void Main ( ) { string s = \\\" geeksforgeeks \\\" ; Console . WriteLine ( no_of_ways ( s ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Largest number M having bit count of N such that difference between their OR and XOR value is maximized | C # program for the above approach ; Function to find the largest number M having the same length in binary form as N such that the difference between N | M and N ^ M is maximum ; Find the most significant bit of N ; Initialize M ; Set all the bits of M ; Return the answer ; Driver Code ; Given number N ; Function call\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static int maxORminusXOR ( int N ) { int MSB = ( int ) Math . Ceiling ( Math . Log ( N ) ) ; int M = 0 ; for ( int i = 0 ; i <= MSB ; i ++ ) M += ( 1 << i ) ; return M ; } public static void Main ( String [ ] args ) { int N = 10 ; Console . Write ( maxORminusXOR ( N ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Minimum decrements or division by a proper divisor required to reduce N to 1 | Function to find the minimum number of steps required to reduce N to 1 ; Stores the number of steps required ; If the value of N is equal to 2 or N is odd ; Decrement N by 1 ; Increment cnt by 1 ; If N is even ; Update N ; Increment cnt by 1 ; Return the number of steps obtained ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def reduceToOne ( N ) :\\n\\tcnt = 0\\n\\twhile ( N != 1 ) :\\n\\t\\tif ( N == 2 or ( N % 2 == 1 ) ) :\\n\\t\\t\\tN = N - 1\\n\\t\\t\\tcnt += 1\\n\\t\\telif ( N % 2 == 0 ) :\\n\\t\\t\\tN = N \\/ ( N \\/ 2 )\\n\\t\\t\\tcnt += 1\\n\\treturn cnt\\nif __name__ == ' _ _ main _ _ ' :\\n\\tN = 35\\n\\tprint ( reduceToOne ( N ) )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"Check for Majority Element in a sorted array | C Program to check for majority element in a sorted array ; get last index according to n ( even or odd ) ; search for first occurrence of x in arr [ ] ; check if x is present and is present more than n \\/ 2 times ; Driver program to check above function\\nHow can the above be solved in C?\",\"targets\":\"# include \\n# include \\nbool isMajority ( int arr [ ] , int n , int x ) { int i ; int last_index = n % 2 ? ( n \\/ 2 + 1 ) : ( n \\/ 2 ) ; for ( i = 0 ; i < last_index ; i ++ ) { if ( arr [ i ] == x && arr [ i + n \\/ 2 ] == x ) return 1 ; } return 0 ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 4 , 4 , 4 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; int x = 4 ; if ( isMajority ( arr , n , x ) ) printf ( \\\" % d ▁ appears ▁ more ▁ than ▁ % d ▁ times ▁ in ▁ arr [ ] \\\" , x , n \\/ 2 ) ; else printf ( \\\" % d ▁ does ▁ not ▁ appear ▁ more ▁ than ▁ % d ▁ times ▁ in ▁ arr [ ] \\\" , x , n \\/ 2 ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Check if a string can be made equal to another string by swapping or replacement of characters | C ++ program for the above approach ; Function to find if given strings are same or not ; Base Condition ; Stores frequency of characters of the string str1 and str2 ; Traverse strings str1 & str2 and store frequencies in a [ ] and b [ ] ; Check if both strings have same characters or not ; If a character is present in one string and is not in another string , return false ; Sort the array a [ ] and b [ ] ; Check arrays a and b contain the same frequency or not ; If the frequencies are not the same after sorting ; At this point , str1 can be converted to str2 ; Driver Code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; bool sameStrings ( string str1 , string str2 ) { int N = str1 . length ( ) ; int M = str2 . length ( ) ; if ( N != M ) { return false ; } int a [ 256 ] = { 0 } , b [ 256 ] = { 0 } ; for ( int i = 0 ; i < N ; i ++ ) { a [ str1 [ i ] - ' a ' ] ++ ; b [ str2 [ i ] - ' a ' ] ++ ; } int i = 0 ; while ( i < 256 ) { if ( ( a [ i ] == 0 && b [ i ] == 0 ) || ( a [ i ] != 0 && b [ i ] != 0 ) ) { i ++ ; } else { return false ; } } sort ( a , a + 256 ) ; sort ( b , b + 256 ) ; for ( int i = 0 ; i < 256 ; i ++ ) { if ( a [ i ] != b [ i ] ) return false ; } return true ; } int main ( ) { string S1 = \\\" cabbba \\\" , S2 = \\\" abbccc \\\" ; if ( sameStrings ( S1 , S2 ) ) cout << \\\" YES \\\" << endl ; else cout << \\\" ▁ NO \\\" << endl ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Find other two sides and angles of a right angle triangle | Javascript program to print all sides and angles of right angle triangle given one side ; Function to find angle A Angle in front of side a ; applied cosine rule ; convert into degrees ; Function to find angle B Angle in front of side b ; applied cosine rule ; convert into degrees and return ; Function to print all angles of the right angled triangle ; for calculate angle A ; for calculate angle B ; Function to find other two sides of the right angled triangle ; if n is odd ; case of n = 1 handled separately ; case of n = 2 handled separately ; Print angles of the triangle ; Driver Code\\\"\\nSolution in Javascript:\",\"targets\":\"let PI = 3.1415926535 ; function findAnglesA ( a , b , c ) { let A = Math . acos ( ( b * b + c * c - a * a ) \\/ ( 2 * b * c ) ) ; return A * 180 \\/ PI ; } function findAnglesB ( a , b , c ) { let B = Math . acos ( ( a * a + c * c - b * b ) \\/ ( 2 * a * c ) ) ; return B * 180 \\/ PI ; } function printAngles ( a , b , c ) { let x = a ; let y = b ; let z = c ; let A = findAnglesA ( x , y , z ) ; let B = findAnglesB ( x , y , z ) ; document . write ( \\\" \\\" + A + \\\" \\\" + B + \\\" \\\" + 90 ) ; } function printOtherSides ( n ) { let b = 0 , c = 0 ; if ( ( n & 1 ) > 0 ) { if ( n == 1 ) document . write ( - 1 ) ; else { b = ( n * n - 1 ) \\/ 2 ; c = ( n * n + 1 ) \\/ 2 ; document . write ( \\\" \\\" + b + \\\" \\\" + c ) ; } } else { if ( n == 2 ) document . write ( - 1 ) ; else { b = n * n \\/ 4 - 1 ; c = n * n \\/ 4 + 1 ; document . write ( \\\" \\\" + b + \\\" \\\" + c + \\\" \\\" ) ; } } printAngles ( n , b , c ) ; } let a = 12 ; printOtherSides ( a ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Sum of the first N terms of the series 2 , 10 , 30 , 68 , ... . | Java program to find sum of first n terms ; Function to calculate the sum ; Driver code ; number of terms to be included in the sum ; find the Sum\\\"\\nSolution in Java:\",\"targets\":\"public class GFG { static int calculateSum ( int n ) { return n * ( n + 1 ) \\/ 2 + ( int ) Math . pow ( ( n * ( n + 1 ) \\/ 2 ) , 2 ) ; } public static void main ( String args [ ] ) { int n = 3 ; System . out . println ( \\\" Sum ▁ = ▁ \\\" + calculateSum ( n ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Find the maximum sum leaf to root path in a Binary Tree | C program to find maximum sum leaf to root path in Binary Tree ; A tree node structure ; A utility function that prints all nodes on the path from root to target_leaf ; base case ; return true if this node is the target_leaf or target leaf is present in one of its descendants ; This function Sets the target_leaf_ref to refer the leaf node of the maximum path sum . Also , returns the max_sum using max_sum_ref ; Update current sum to hold sum of nodes on path from root to this node ; If this is a leaf node and path to this node has maximum sum so far , then make this node target_leaf ; If this is not a leaf node , then recur down to find the target_leaf ; Returns the maximum sum and prints the nodes on max sum path ; base case ; find the target leaf and maximum sum ; print the path from root to the target leaf ; return maximum sum ; Utility function to create a new Binary Tree node ; Driver function to test above functions\\\"\\nSolution in C:\",\"targets\":\"#include \\n#include \\n#include \\n#include \\nstruct node { int data ; struct node * left ; struct node * right ; } ; bool printPath ( struct node * root , struct node * target_leaf ) { if ( root == NULL ) return false ; if ( root == target_leaf || printPath ( root -> left , target_leaf ) || printPath ( root -> right , target_leaf ) ) { printf ( \\\" % d ▁ \\\" , root -> data ) ; return true ; } return false ; } void getTargetLeaf ( struct node * node , int * max_sum_ref , int curr_sum , struct node * * target_leaf_ref ) { if ( node == NULL ) return ; curr_sum = curr_sum + node -> data ; if ( node -> left == NULL && node -> right == NULL ) { if ( curr_sum > * max_sum_ref ) { * max_sum_ref = curr_sum ; * target_leaf_ref = node ; } } getTargetLeaf ( node -> left , max_sum_ref , curr_sum , target_leaf_ref ) ; getTargetLeaf ( node -> right , max_sum_ref , curr_sum , target_leaf_ref ) ; } int maxSumPath ( struct node * node ) { if ( node == NULL ) return 0 ; struct node * target_leaf ; int max_sum = INT_MIN ; getTargetLeaf ( node , & max_sum , 0 , & target_leaf ) ; printPath ( node , target_leaf ) ; return max_sum ; } struct node * newNode ( int data ) { struct node * temp = ( struct node * ) malloc ( sizeof ( struct node ) ) ; temp -> data = data ; temp -> left = NULL ; temp -> right = NULL ; return temp ; } int main ( ) { struct node * root = NULL ; root = newNode ( 10 ) ; root -> left = newNode ( -2 ) ; root -> right = newNode ( 7 ) ; root -> left -> left = newNode ( 8 ) ; root -> left -> right = newNode ( -4 ) ; printf ( \\\" Following ▁ are ▁ the ▁ nodes ▁ on ▁ the ▁ maximum ▁ \\\" \\\" sum ▁ path ▁ \\n \\\" ) ; int sum = maxSumPath ( root ) ; printf ( \\\" Sum of the nodes is % d \\\" , sum ) ; getchar ( ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Modular exponentiation ( Recursive ) | Recursive C program to compute modular power ; Base cases ; If B is even ; If B is odd ; Driver program to test above functions\\\"\\nSolution in C:\",\"targets\":\"#include \\nint exponentMod ( int A , int B , int C ) { if ( A == 0 ) return 0 ; if ( B == 0 ) return 1 ; long y ; if ( B % 2 == 0 ) { y = exponentMod ( A , B \\/ 2 , C ) ; y = ( y * y ) % C ; } else { y = A % C ; y = ( y * exponentMod ( A , B - 1 , C ) % C ) % C ; } return ( int ) ( ( y + C ) % C ) ; } int main ( ) { int A = 2 , B = 5 , C = 13 ; printf ( \\\" Power ▁ is ▁ % d \\\" , exponentMod ( A , B , C ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Fibonacci Cube Graph | C # code to find vertices in a fibonacci cube graph of order n ; function to find fibonacci number ; function for finding number of vertices in fibonacci cube graph ; return fibonacci number for f ( n + 2 ) ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static int fib ( int n ) { if ( n <= 1 ) return n ; return fib ( n - 1 ) + fib ( n - 2 ) ; } static int findVertices ( int n ) { return fib ( n + 2 ) ; } static void Main ( ) { int n = 3 ; Console . Write ( findVertices ( n ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Largest number made up of X and Y with count of X divisible by Y and of Y by X | Function to generate and return the largest number ; Store the smaller in Y ; Store the larger in X ; Stores respective counts ; If N is divisible by Y ; Append X , N times to the answer ; Reduce N to zero ; Reduce N by X ; Append Y , X times to the answer ; If number can be formed ; Otherwise ; Driver Code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function largestNumber ( n , X , Y ) { let maxm = Math . max ( X , Y ) ; Y = X + Y - maxm ; X = maxm ; let Xs = 0 ; let Ys = 0 ; while ( n > 0 ) { if ( n % Y == 0 ) { Xs += n ; n = 0 ; } else { n -= X ; Ys += X ; } } if ( n == 0 ) { while ( Xs -- > 0 ) document . write ( X ) ; while ( Ys -- > 0 ) document . write ( Y ) ; } else document . write ( \\\" \\\" ) ; } let n = 19 , X = 7 , Y = 5 ; largestNumber ( n , X , Y ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"Program to find the sum of a Series ( 1 * 1 ) + ( 2 * 2 ) + ( 3 * 3 ) + ( 4 * 4 ) + ( 5 * 5 ) + ... + ( n * n ) | C program to calculate the following series ; Function to calculate the following series ; Driver Code\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint Series ( int n ) { int i ; int sums = 0 ; for ( i = 1 ; i <= n ; i ++ ) sums += ( i * i ) ; return sums ; } int main ( ) { int n = 3 ; int res = Series ( n ) ; printf ( \\\" % d \\\" , res ) ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Find average of two numbers using bit operation | C # implementation of the approach ; Function to return the average of x and y using bit operations ; Calculate the average Floor value of ( x + y ) \\/ 2 ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int getAverage ( int x , int y ) { int avg = ( x & y ) + ( ( x ^ y ) >> 1 ) ; return avg ; } public static void Main ( ) { int x = 10 , y = 9 ; Console . WriteLine ( getAverage ( x , y ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Maximum sum possible from given Matrix by performing given operations | Function to print the maximum sum ; Dp table ; Initializing dp array with 0 s ; Base case ; Traverse each column ; Update answer for both rows ; Print the maximum sum ; Given array ; Number of Columns ; Function calls\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function maxSum ( arr , n , m ) { let dp = new Array ( n ) ; for ( var i = 0 ; i < dp . length ; i ++ ) { dp [ i ] = new Array ( 2 ) ; } for ( let i = 0 ; i < 2 ; i ++ ) { for ( let j = 0 ; j <= m ; j ++ ) { dp [ i ] [ j ] = 0 ; } } dp [ 0 ] [ m - 1 ] = arr [ 0 ] [ m - 1 ] ; dp [ 1 ] [ m - 1 ] = arr [ 1 ] [ m - 1 ] ; for ( let j = m - 2 ; j >= 0 ; j -- ) { for ( let i = 0 ; i < 2 ; i ++ ) { if ( i == 1 ) { dp [ i ] [ j ] = Math . max ( arr [ i ] [ j ] + dp [ 0 ] [ j + 1 ] , arr [ i ] [ j ] + dp [ 0 ] [ j + 2 ] ) ; } else { dp [ i ] [ j ] = Math . max ( arr [ i ] [ j ] + dp [ 1 ] [ j + 1 ] , arr [ i ] [ j ] + dp [ 1 ] [ j + 2 ] ) ; } } } document . write ( Math . max ( dp [ 0 ] [ 0 ] , dp [ 1 ] [ 0 ] ) ) ; } let arr = [ [ 1 , 50 , 21 , 5 ] , [ 2 , 10 , 10 , 5 ] ] ; let N = arr [ 0 ] . length ; maxSum ( arr , 2 , N ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"First digit in product of an array of numbers | returns the first digit of product of elements of arr [ ] ; stores the logarithm of product of elements of arr [ ] ; fractional ( s ) = s - floor ( s ) ; ans = 10 ^ fract_s ; Driver Code\\\"\\nSolution in Javascript:\",\"targets\":\"function FirstDigit ( arr , n ) { let S = 0 ; for ( let i = 0 ; i < n ; i ++ ) S = S + Math . log10 ( arr [ i ] * 1.0 ) ; let fract_S = S - Math . floor ( S ) ; let ans = parseInt ( Math . pow ( 10 , fract_S ) , 10 ) ; return ans ; } let arr = [ 5 , 8 , 3 , 7 ] ; let n = arr . length ; document . write ( FirstDigit ( arr , n ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Ternary Search | Function to perform Ternary Search ; Find the mid1 and mid2 ; Check if key is present at any mid ; Since key is not present at mid , check in which region it is present then repeat the Search operation in that region ; The key lies in between l and mid1 ; The key lies in between mid2 and r ; The key lies in between mid1 and mid2 ; Key not found ; Get the array Sort the array if not sorted ; Starting index ; length of array ; Key to be searched in the array ; Search the key using ternarySearch ; Print the result ; Key to be searched in the array ; Search the key using ternarySearch ; Print the result\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function ternarySearch ( $ l , $ r , $ key , $ ar ) { if ( $ r >= $ l ) { $ mid1 = ( int ) ( $ l + ( $ r - $ l ) \\/ 3 ) ; $ mid2 = ( int ) ( $ r - ( $ r - $ l ) \\/ 3 ) ; if ( $ ar [ $ mid1 ] == $ key ) { return $ mid1 ; } if ( $ ar [ $ mid2 ] == $ key ) { return $ mid2 ; } if ( $ key < $ ar [ $ mid1 ] ) { return ternarySearch ( $ l , $ mid1 - 1 , $ key , $ ar ) ; } else if ( $ key > $ ar [ $ mid2 ] ) { return ternarySearch ( $ mid2 + 1 , $ r , $ key , $ ar ) ; } else { return ternarySearch ( $ mid1 + 1 , $ mid2 - 1 , $ key , $ ar ) ; } } return -1 ; } $ ar = array ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ) ; $ l = 0 ; $ r = 9 ; $ key = 5 ; $ p = ternarySearch ( $ l , $ r , $ key , $ ar ) ; echo \\\" Index ▁ of ▁ \\\" , $ key , \\\" ▁ is ▁ \\\" , ( int ) $ p , \\\" \\n \\\" ; $ key = 50 ; $ p = ternarySearch ( $ l , $ r , $ key , $ ar ) ; echo \\\" Index ▁ of ▁ \\\" , $ key , \\\" ▁ is ▁ \\\" , ( int ) $ p , \\\" \\n \\\" ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Maximum triplet sum in array | This function assumes that there are at least three elements in arr [ ] . ; sort the given array ; After sorting the array . Add last three element of the given array ; Driver code\\\"\\nSolution in php:\",\"targets\":\"< ? php function maxTripletSum ( $ arr , $ n ) { sort ( $ arr ) ; return $ arr [ $ n - 1 ] + $ arr [ $ n - 2 ] + $ arr [ $ n - 3 ] ; } $ arr = array ( 1 , 0 , 8 , 6 , 4 , 2 ) ; $ n = count ( $ arr ) ; echo maxTripletSum ( $ arr , $ n ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Generate all possible sorted arrays from alternate elements of two given sorted arrays | Function to generates and prints all sorted arrays from alternate elements of ' A [ i . . m - 1 ] ' and ' B [ j . . n - 1 ] ' If ' flag ' is true , then current element is to be included from A otherwise from B . ' len ' is the index in output array C [ ] . We print output array each time before including a character from A only if length of output array is greater than 0. We try than all possible combinations ; Include valid element from A ; Print output if there is at least one ' B ' in output array ' C ' ; Recur for all elements of A after current index ; this block works for the very first call to include the first element in the output array ; don 't increment lem as B is included yet ; include valid element from A and recur ; Include valid element from B and recur ; Wrapper function ; output array ; A utility function to print an array ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function generateUtil ( & $ A , & $ B , & $ C , $ i , $ j , $ m , $ n , $ len , $ flag ) { if ( $ flag ) { if ( $ len ) printArr ( $ C , $ len + 1 ) ; for ( $ k = $ i ; $ k < $ m ; $ k ++ ) { if ( ! $ len ) { $ C [ $ len ] = $ A [ $ k ] ; generateUtil ( $ A , $ B , $ C , $ k + 1 , $ j , $ m , $ n , $ len , ! $ flag ) ; } else { if ( $ A [ $ k ] > $ C [ $ len ] ) { $ C [ $ len + 1 ] = $ A [ $ k ] ; generateUtil ( $ A , $ B , $ C , $ k + 1 , $ j , $ m , $ n , $ len + 1 , ! $ flag ) ; } } } } else { for ( $ l = $ j ; $ l < $ n ; $ l ++ ) { if ( $ B [ $ l ] > $ C [ $ len ] ) { $ C [ $ len + 1 ] = $ B [ $ l ] ; generateUtil ( $ A , $ B , $ C , $ i , $ l + 1 , $ m , $ n , $ len + 1 , ! $ flag ) ; } } } } function generate ( & $ A , & $ B , $ m , $ n ) { $ C = array_fill ( 0 , ( $ m + $ n ) , NULL ) ; generateUtil ( $ A , $ B , $ C , 0 , 0 , $ m , $ n , 0 , true ) ; } function printArr ( & $ arr , $ n ) { for ( $ i = 0 ; $ i < $ n ; $ i ++ ) echo $ arr [ $ i ] . \\\" ▁ \\\" ; echo \\\" \\n \\\" ; } $ A = array ( 10 , 15 , 25 ) ; $ B = array ( 5 , 20 , 30 ) ; $ n = sizeof ( $ A ) ; $ m = sizeof ( $ B ) ; generate ( $ A , $ B , $ n , $ m ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Print all pairs with given sum | C # program to find triplets in a given array whose sum is equal to given sum . ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; public class SumOfPairs { public void pairedElements ( int [ ] arr , int sum ) { int low = 0 ; int high = arr . Length - 1 ; while ( low < high ) { if ( arr [ low ] + arr [ high ] == sum ) { Console . WriteLine ( \\\" The ▁ pair ▁ is ▁ : ▁ ( \\\" + arr [ low ] + \\\" , ▁ \\\" + arr [ high ] + \\\" ) \\\" ) ; } if ( arr [ low ] + arr [ high ] > sum ) { high -- ; } else { low ++ ; } } } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 4 , - 2 , 6 , 8 , 9 , 11 } ; Array . Sort ( arr ) ; SumOfPairs sp = new SumOfPairs ( ) ; sp . pairedElements ( arr , 6 ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Binomial Coefficient | DP | JAVA Code for Dynamic Programming | Set 9 ( Binomial Coefficient ) ; Returns value of Binomial Coefficient C ( n , k ) ; Base Cases ; Recur ; Driver program to test above function\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { static int binomialCoeff ( int n , int k ) { if ( k > n ) return 0 ; if ( k == 0 k == n ) return 1 ; return binomialCoeff ( n - 1 , k - 1 ) + binomialCoeff ( n - 1 , k ) ; } public static void main ( String [ ] args ) { int n = 5 , k = 2 ; System . out . printf ( \\\" Value ▁ of ▁ C ( % d , ▁ % d ) ▁ is ▁ % d ▁ \\\" , n , k , binomialCoeff ( n , k ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Check if a string can be transformed to another by sorting substrings | Function to check if str1 can be transformed to t by sorting substrings ; Occur [ i ] stores the indices of char ( ' a ' + i ) in string s ; idx [ i ] stores the next available index of char ( ' a ' + i ) in occur [ i ] ; If this char is not available anymore ; Conversion not possible ; If one of the smaller characters is available and occurs before ; Conversion not possible ; Print the answer ; Driver Code\\\"\\nSolution in Javascript:\",\"targets\":\"function canTransform ( s , t ) { var n = s . length ; var occur = Array . from ( Array ( 26 ) , ( ) => new Array ( ) ) ; for ( var x = 0 ; x < n ; x ++ ) { var ch = s [ x ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ; occur [ ch ] . push ( x ) ; } var idx = Array ( 26 ) . fill ( 0 ) ; var poss = true ; for ( var x = 0 ; x < n ; x ++ ) { var ch = t [ x ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ; if ( idx [ ch ] >= occur [ ch ] . length ) { poss = false ; break ; } for ( var small = 0 ; small < ch ; small ++ ) { if ( idx [ small ] < occur [ small ] . length && occur [ small ] [ idx [ small ] ] < occur [ ch ] [ idx [ ch ] ] ) { poss = false ; break ; } } idx [ ch ] ++ ; } if ( poss ) { document . write ( \\\" \\\" ) ; } else { document . write ( \\\" \\\" ) ; } } var s , t ; s = \\\" \\\" ; t = \\\" \\\" ; canTransform ( s , t ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Polygon with maximum sides that can be inscribed in an N | Java program for the above approach ; Function to find the maximum sided polygon that can be inscribed ; Base Case ; Return n \\/ 2 if n is even Otherwise , return - 1 ; Driver Code ; Given N ; Function Call\\\"\\nSolution in Java:\",\"targets\":\"import java . util . * ; class GFG { static int MaximumSides ( int n ) { if ( n < 4 ) return - 1 ; return n % 2 == 0 ? n \\/ 2 : - 1 ; } public static void main ( String [ ] args ) { int N = 8 ; System . out . print ( MaximumSides ( N ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Ternary Search | Function to perform Ternary Search ; Find the mid1 and mid2 ; Check if key is present at any mid ; Since key is not present at mid , check in which region it is present then repeat the Search operation in that region ; The key lies in between l and mid1 ; The key lies in between mid2 and r ; The key lies in between mid1 and mid2 ; Key not found ; Get the array Sort the array if not sorted ; Starting index ; length of array ; Key to be searched in the array ; Search the key using ternarySearch ; Print the result ; Key to be searched in the array ; Search the key using ternarySearch ; Print the result\\\"\\nSolution in php:\",\"targets\":\"< ? php function ternarySearch ( $ l , $ r , $ key , $ ar ) { if ( $ r >= $ l ) { $ mid1 = ( int ) ( $ l + ( $ r - $ l ) \\/ 3 ) ; $ mid2 = ( int ) ( $ r - ( $ r - $ l ) \\/ 3 ) ; if ( $ ar [ $ mid1 ] == $ key ) { return $ mid1 ; } if ( $ ar [ $ mid2 ] == $ key ) { return $ mid2 ; } if ( $ key < $ ar [ $ mid1 ] ) { return ternarySearch ( $ l , $ mid1 - 1 , $ key , $ ar ) ; } else if ( $ key > $ ar [ $ mid2 ] ) { return ternarySearch ( $ mid2 + 1 , $ r , $ key , $ ar ) ; } else { return ternarySearch ( $ mid1 + 1 , $ mid2 - 1 , $ key , $ ar ) ; } } return -1 ; } $ ar = array ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ) ; $ l = 0 ; $ r = 9 ; $ key = 5 ; $ p = ternarySearch ( $ l , $ r , $ key , $ ar ) ; echo \\\" Index ▁ of ▁ \\\" , $ key , \\\" ▁ is ▁ \\\" , ( int ) $ p , \\\" \\n \\\" ; $ key = 50 ; $ p = ternarySearch ( $ l , $ r , $ key , $ ar ) ; echo \\\" Index ▁ of ▁ \\\" , $ key , \\\" ▁ is ▁ \\\" , ( int ) $ p , \\\" \\n \\\" ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Check if the characters of a given string are in alphabetical order | Function that checks whether the string is in alphabetical order or not ; length of the string ; create a character array of the length of the string ; assign the string to character array ; sort the character array ; check if the character array is equal to the string or not ; Driver code ; check whether the string is in alphabetical order or not\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php Function isAlphabaticOrder ( $ s ) { $ n = strlen ( $ s ) ; $ c = array ( ) ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { $ c [ $ i ] = $ s [ $ i ] ; } sort ( $ c ) ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) if ( $ c [ $ i ] != $ s [ $ i ] ) return false ; return true ; } $ s = \\\" aabbbcc \\\" ; if ( isAlphabaticOrder ( $ s ) ) echo \\\" Yes \\\" ; else echo \\\" No \\\" ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Hoax Number | Function to find distinct prime factors of given number n ; n is odd at this point , since it is no longer divisible by 2. So we can test only for the odd numbers , whether they are factors of n ; Check if i is prime factor ; This condition is to handle the case when n is a prime number greater than 2 ; Function to calculate sum of digits of distinct prime factors of given number n and sum of digits of number n and compare the sums obtained ; Distinct prime factors of n are being stored in vector pf ; If n is a prime number , it cannot be a hoax number ; Finding sum of digits of distinct prime factors of the number n ; Finding sum of digits in current prime factor pf [ i ] . ; Finding sum of digits of number n ; Comparing the two calculated sums ; Driver Method\\\"\\nSolution in Javascript:\",\"targets\":\"function primeFactors ( n ) { var res = [ ] ; if ( n % 2 == 0 ) { while ( n % 2 == 0 ) n = parseInt ( n \\/ 2 ) ; res . push ( 2 ) ; } for ( var i = 3 ; i <= Math . sqrt ( n ) ; i = i + 2 ) { if ( n % i == 0 ) { while ( n % i == 0 ) n = parseInt ( n \\/ i ) ; res . push ( i ) ; } } if ( n > 2 ) res . push ( n ) ; return res ; } function isHoax ( n ) { var pf = primeFactors ( n ) ; if ( pf [ 0 ] == n ) return false ; var all_pf_sum = 0 ; for ( var i = 0 ; i < pf . length ; i ++ ) { var pf_sum ; for ( pf_sum = 0 ; pf [ i ] > 0 ; pf_sum += pf [ i ] % 10 , pf [ i ] = parseInt ( pf [ i ] \\/ 10 ) ) ; all_pf_sum += pf_sum ; } var sum_n ; for ( sum_n = 0 ; n > 0 ; sum_n += n % 10 , n = parseInt ( n \\/ 10 ) ) ; return sum_n == all_pf_sum ; } var n = 84 ; if ( isHoax ( n ) ) document . write ( \\\" \\\" ) ; else document . write ( \\\" \\\" ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Minimum number of points to be removed to get remaining points on one side of axis | Function to find the minimum number of points ; Number of points on the left of Y - axis . ; Number of points on the right of Y - axis . ; Number of points above X - axis . ; Number of points below X - axis . ; Driver Code\\\"\\nSolution in Javascript:\",\"targets\":\"function findmin ( p , n ) { let a = 0 , b = 0 , c = 0 , d = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( p [ i ] [ 0 ] <= 0 ) a ++ ; else if ( p [ i ] [ 0 ] >= 0 ) b ++ ; if ( p [ i ] [ 1 ] >= 0 ) c ++ ; else if ( p [ i ] [ 1 ] <= 0 ) d ++ ; } return Math . min ( Math . min ( a , b ) , Math . min ( c , d ) ) ; } let p = [ [ 1 , 1 ] , [ 2 , 2 ] , [ - 1 , - 1 ] , [ - 2 , 2 ] ] let n = p . length ; document . write ( findmin ( p , n ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Sieve of Eratosthenes | C ++ program to print all primes smaller than or equal to n using Sieve of Eratosthenes ; Create a boolean array \\\" prime [ 0 . . n ] \\\" and initialize all entries it as true . A value in prime [ i ] will finally be false if i is Not a prime , else true . ; If prime [ p ] is not changed , then it is a prime ; Update all multiples of p greater than or equal to the square of it numbers which are multiple of p and are less than p ^ 2 are already been marked . ; Print all prime numbers ; Driver Code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; void SieveOfEratosthenes ( int n ) { bool prime [ n + 1 ] ; memset ( prime , true , sizeof ( prime ) ) ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= n ; i += p ) prime [ i ] = false ; } } for ( int p = 2 ; p <= n ; p ++ ) if ( prime [ p ] ) cout << p << \\\" ▁ \\\" ; } int main ( ) { int n = 30 ; cout << \\\" Following ▁ are ▁ the ▁ prime ▁ numbers ▁ smaller ▁ \\\" << \\\" ▁ than ▁ or ▁ equal ▁ to ▁ \\\" << n << endl ; SieveOfEratosthenes ( n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Find Cube root of a number using Log function | Python3 program to find cube root of a number using logarithm ; Function to find the cube root ; Calculate the cube root ; Return the final answer ; Driver code\\\"\\nSolution in Python:\",\"targets\":\"import numpy as np\\ndef cubeRoot ( n ) :\\n\\tans = pow ( 3 , ( 1.0 \\/ 3 ) * ( np . log ( n ) \\/ np . log ( 3 ) ) )\\n\\treturn ans\\nN = 8\\nprint ( \\\" % .2f \\\" % cubeRoot ( N ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Maximum decimal value path in a binary matrix | C ++ program to find maximum decimal value path in binary matrix ; Returns maximum decimal value in binary matrix . Here p indicate power of 2 ; Out of matrix boundary ; If current matrix value is 1 then return result + power ( 2 , p ) else result ; Driver program\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; #define N 4\\nlong long int maxDecimalValue ( int mat [ ] [ N ] , int i , int j , int p ) { if ( i >= N j >= N ) return 0 ; int result = max ( maxDecimalValue ( mat , i , j + 1 , p + 1 ) , maxDecimalValue ( mat , i + 1 , j , p + 1 ) ) ; if ( mat [ i ] [ j ] == 1 ) return pow ( 2 , p ) + result ; else return result ; } int main ( ) { int mat [ ] [ 4 ] = { { 1 , 1 , 0 , 1 } , { 0 , 1 , 1 , 0 } , { 1 , 0 , 0 , 1 } , { 1 , 0 , 1 , 1 } , } ; cout << maxDecimalValue ( mat , 0 , 0 , 0 ) << endl ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Hyperfactorial of a number | C ++ program to find the hyperfactorial of a number using boost libraries ; function to calculate the value of hyperfactorial ; initialise the val to 1 ; 1 ^ 1 * 2 ^ 2 * 3 ^ 3. . . . ; returns the hyperfactorial of a number ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\n#include \\nusing namespace boost :: multiprecision ; using namespace std ; int1024_t boost_hyperfactorial ( int num ) { int1024_t val = 1 ; for ( int i = 1 ; i <= num ; i ++ ) { for ( int j = 1 ; j <= i ; j ++ ) { val *= i ; } } return val ; } int main ( ) { int num = 5 ; cout << boost_hyperfactorial ( num ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"k | C # program to print k - th distinct element in a given array ; Returns k - th distinct element in arr ; Check if current element is present somewhere else . ; If element is unique ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int printKDistinct ( int [ ] arr , int n , int k ) { int dist_count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int j ; for ( j = 0 ; j < n ; j ++ ) if ( i != j && arr [ j ] == arr [ i ] ) break ; if ( j == n ) dist_count ++ ; if ( dist_count == k ) return arr [ i ] ; } return - 1 ; } public static void Main ( ) { int [ ] ar = { 1 , 2 , 1 , 3 , 4 , 2 } ; int n = ar . Length ; int k = 2 ; Console . Write ( printKDistinct ( ar , n , k ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Number of paths with exactly k coins | A Dynamic Programming based Python3 program to count paths with exactly ' k ' coins ; Base cases ; If this subproblem is already solved ; ( m , n ) can be reached either through ( m - 1 , n ) or through ( m , n - 1 ) ; A wrapper over pathCountDPRecDP ( ) ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"R = 3\\nC = 3\\nMAX_K = 1000\\ndef pathCountDPRecDP ( mat , m , n , k ) :\\n\\tif m < 0 or n < 0 :\\n\\t\\treturn 0\\n\\telif m == 0 and n == 0 :\\n\\t\\treturn k == mat [ m ] [ n ]\\n\\tif ( dp [ m ] [ n ] [ k ] != - 1 ) :\\n\\t\\treturn dp [ m ] [ n ] [ k ]\\n\\tdp [ m ] [ n ] [ k ] = ( pathCountDPRecDP ( mat , m - 1 , n , k - mat [ m ] [ n ] ) + pathCountDPRecDP ( mat , m , n - 1 , k - mat [ m ] [ n ] ) )\\n\\treturn dp [ m ] [ n ] [ k ]\\ndef pathCountDP ( mat , k ) :\\n\\treturn pathCountDPRecDP ( mat , R - 1 , C - 1 , k )\\nk = 12\\ndp = [ [ [ - 1 for col in range ( MAX_K ) ] for col in range ( C ) ] for row in range ( R ) ]\\nmat = [ [ 1 , 2 , 3 ] , [ 4 , 6 , 5 ] , [ 3 , 2 , 1 ] ]\\nprint ( pathCountDP ( mat , k ) )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Smallest and Largest sum of two n | Function to return the smallest sum of 2 n - digit numbers ; Function to return the largest sum of 2 n - digit numbers ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function smallestSum ( $ n ) { if ( $ n == 1 ) return 0 ; return ( 2 * pow ( 10 , $ n - 1 ) ) ; } function largestSum ( $ n ) { return 2 * ( pow ( 10 , $ n ) - 1 ) ; } $ n = 4 ; echo \\\" Largest = \\\" ▁ . ▁ largestSum ( $ n ) ▁ . ▁ \\\" \\\" ; \\n echo ▁ \\\" Smallest = \\\" ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Check if two nodes are on same path in a tree | Set 2 | C # program to check if two nodes are on same path in a tree without using any extra space ; Function to filter the return Values ; Utility function to check if nodes are on same path or not ; Condition to check if any vertex is equal to given two vertex or not ; Check if the current position has 1 ; Recursive call ; Return LCA ; Function to check if nodes lies on same path or not ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int filter ( int x , int y , int z ) { if ( x != - 1 && y != - 1 ) { return z ; } return x == - 1 ? y : x ; } static int samePathUtil ( int [ , ] mtrx , int vrtx , int v1 , int v2 , int i ) { int ans = - 1 ; if ( i == v1 i == v2 ) return i ; for ( int j = 0 ; j < vrtx ; j ++ ) { if ( mtrx [ i , j ] == 1 ) { ans = filter ( ans , samePathUtil ( mtrx , vrtx , v1 , v2 , j ) , i ) ; } } return ans ; } static bool isVertexAtSamePath ( int [ , ] mtrx , int vrtx , int v1 , int v2 , int i ) { int lca = samePathUtil ( mtrx , vrtx , v1 - 1 , v2 - 1 , i ) ; if ( lca == v1 - 1 lca == v2 - 1 ) return true ; return false ; } public static void Main ( String [ ] args ) { int vrtx = 7 ; int [ , ] mtrx = { { 0 , 1 , 1 , 1 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 , 1 , 0 , 0 } , { 0 , 0 , 0 , 0 , 0 , 1 , 0 } , { 0 , 0 , 0 , 0 , 0 , 0 , 1 } , { 0 , 0 , 0 , 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 , 0 , 0 , 0 } } ; int v1 = 1 , v2 = 5 ; if ( isVertexAtSamePath ( mtrx , vrtx , v1 , v2 , 0 ) ) Console . Write ( \\\" Yes \\\" ) ; else Console . Write ( \\\" No \\\" ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Minimize coins required to obtain all possible values up to N | C # program to implement the above approach ; Function to find minimum count of { 1 , 2 , 5 } valued coins required to make a change of all values in the range [ 1 , N ] ; Number of 5 valueds coins required ; Number of 1 valued coins required ; Number of 2 valued coins required ; Driver Code\\\"\\nSolution in C#:\",\"targets\":\"using System ; public class GFG { static void find ( int N ) { int T , F , O ; F = ( int ) ( ( N - 4 ) \\/ 5 ) ; if ( ( ( N - 5 * F ) % 2 ) == 0 ) { O = 2 ; } else { O = 1 ; } T = ( int ) Math . Floor ( ( double ) ( N - 5 * F - O ) \\/ 2 ) ; Console . WriteLine ( \\\" Count ▁ of ▁ 5 ▁ valueds ▁ coins : ▁ \\\" + F ) ; Console . WriteLine ( \\\" Count ▁ of ▁ 2 ▁ valueds ▁ coins : ▁ \\\" + T ) ; Console . WriteLine ( \\\" Count ▁ of ▁ 1 ▁ valueds ▁ coins : ▁ \\\" + O ) ; } public static void Main ( String [ ] args ) { int N = 8 ; find ( N ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Check in binary array the number represented by a subarray is odd or even | java program to find if a subarray is even or odd . ; prints if subarray is even or odd ; if arr [ r ] = 1 print odd ; if arr [ r ] = 0 print even ; driver code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . io . * ; class GFG { static void checkEVENodd ( int arr [ ] , int n , int l , int r ) { if ( arr [ r ] == 1 ) System . out . println ( \\\" odd \\\" ) ; else System . out . println ( \\\" even \\\" ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 , 0 , 1 } ; int n = arr . length ; checkEVENodd ( arr , n , 1 , 3 ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Rearrange array to maximize sum of GCD of array elements with their respective indices | Java program to implement the above approach ; Function to find the maximum sum of GCD ( arr [ i ] , i ) by rearranging the array ; Stores maximum sum of GCD ( arr [ i ] , i ) by rearranging the array elements ; Update res ; Driver Code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { static int findMaxValByRearrArr ( int arr [ ] , int N ) { int res = 0 ; res = ( N * ( N + 1 ) ) \\/ 2 ; return res ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 2 , 1 } ; int N = arr . length ; System . out . print ( findMaxValByRearrArr ( arr , N ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Break the number into three parts | Function to count number of ways to make the given number n ; Driver code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def count_of_ways ( n ) :\\n\\tcount = 0\\n\\tcount = ( n + 1 ) * ( n + 2 ) \\/\\/ 2\\n\\treturn count\\nn = 3\\nprint ( count_of_ways ( n ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Dynamic Programming | High | Returns maximum amount of task that can be done till day n ; If n is less than equal to 0 , then no solution exists ; Determines which task to choose on day n , then returns the maximum till that day ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function maxTasks ( $ high , $ low , $ n ) { if ( $ n <= 0 ) return 0 ; return max ( $ high [ $ n - 1 ] + maxTasks ( $ high , $ low , ( $ n - 2 ) ) , $ low [ $ n - 1 ] + maxTasks ( $ high , $ low , ( $ n - 1 ) ) ) ; } $ n = 5 ; $ high = array ( 3 , 6 , 8 , 7 , 6 ) ; $ low = array ( 1 , 5 , 4 , 5 , 3 ) ; print ( maxTasks ( $ high , $ low , $ n ) ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Optimal Strategy for a Game | DP | Returns optimal value possible that a player can collect from an array of coins of size n . Note than n must be even ; Create a table to store solutions of subproblems ; Fill table using above recursive formula . Note that the table is filled in diagonal fashion ( similar to http : goo . gl \\/ PQqoS ) , from diagonal elements to table [ 0 ] [ n - 1 ] which is the result . ; Here x is value of F ( i + 2 , j ) , y is F ( i + 1 , j - 1 ) and z is F ( i , j - 2 ) in above recursive formula ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function optimalStrategyOfGame ( $ arr , $ n ) { $ table = array_fill ( 0 , $ n , array_fill ( 0 , $ n , 0 ) ) ; for ( $ gap = 0 ; $ gap < $ n ; ++ $ gap ) { for ( $ i = 0 , $ j = $ gap ; $ j < $ n ; ++ $ i , ++ $ j ) { $ x = ( ( $ i + 2 ) <= $ j ) ? $ table [ $ i + 2 ] [ $ j ] : 0 ; $ y = ( ( $ i + 1 ) <= ( $ j - 1 ) ) ? $ table [ $ i + 1 ] [ $ j - 1 ] : 0 ; $ z = ( $ i <= ( $ j - 2 ) ) ? $ table [ $ i ] [ $ j - 2 ] : 0 ; $ table [ $ i ] [ $ j ] = max ( $ arr [ $ i ] + min ( $ x , $ y ) , $ arr [ $ j ] + min ( $ y , $ z ) ) ; } } return $ table [ 0 ] [ $ n - 1 ] ; } $ arr1 = array ( 8 , 15 , 3 , 7 ) ; $ n = count ( $ arr1 ) ; print ( optimalStrategyOfGame ( $ arr1 , $ n ) . \\\" \\\" ) ; $ arr2 = array ( 2 , 2 , 2 , 2 ) ; $ n = count ( $ arr2 ) ; print ( optimalStrategyOfGame ( $ arr2 , $ n ) . \\\" \\\" ) ; $ arr3 = array ( 20 , 30 , 2 , 2 , 2 , 10 ) ; $ n = count ( $ arr3 ) ; print ( optimalStrategyOfGame ( $ arr3 , $ n ) . \\\" \\\" ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Area of a Circumscribed Circle of a Square | Utiity function ; Driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function areacircumscribed ( a ) { return ( a * a * ( 3.1415 \\/ 2 ) ) ; } let a = 6 ; document . write ( \\\" \\\" , areacircumscribed ( a ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"The Knight 's tour problem | Backtracking | C program for Knight Tour problem ; A utility function to check if i , j are valid indexes for N * N chessboard ; A utility function to print solution matrix sol [ N ] [ N ] ; This function solves the Knight Tour problem using Backtracking . This function mainly uses solveKTUtil ( ) to solve the problem . It returns false if no complete tour is possible , otherwise return true and prints the tour . Please note that there may be more than one solutions , this function prints one of the feasible solutions . ; Initialization of solution matrix ; xMove [ ] and yMove [ ] define next move of Knight . xMove [ ] is for next value of x coordinate yMove [ ] is for next value of y coordinate ; Since the Knight is initially at the first block ; Start from 0 , 0 and explore all tours using solveKTUtil ( ) ; A recursive utility function to solve Knight Tour problem ; Try all next moves from the current coordinate x , y ; backtracking ; Driver Code ; Function Call\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#define N 8\\nint solveKTUtil ( int x , int y , int movei , int sol [ N ] [ N ] , int xMove [ ] , int yMove [ ] ) ; int isSafe ( int x , int y , int sol [ N ] [ N ] ) { return ( x >= 0 && x < N && y >= 0 && y < N && sol [ x ] [ y ] == -1 ) ; } void printSolution ( int sol [ N ] [ N ] ) { for ( int x = 0 ; x < N ; x ++ ) { for ( int y = 0 ; y < N ; y ++ ) printf ( \\\" ▁ % 2d ▁ \\\" , sol [ x ] [ y ] ) ; printf ( \\\" \\n \\\" ) ; } } int solveKT ( ) { int sol [ N ] [ N ] ; for ( int x = 0 ; x < N ; x ++ ) for ( int y = 0 ; y < N ; y ++ ) sol [ x ] [ y ] = -1 ; int xMove [ 8 ] = { 2 , 1 , -1 , -2 , -2 , -1 , 1 , 2 } ; int yMove [ 8 ] = { 1 , 2 , 2 , 1 , -1 , -2 , -2 , -1 } ; sol [ 0 ] [ 0 ] = 0 ; if ( solveKTUtil ( 0 , 0 , 1 , sol , xMove , yMove ) == 0 ) { printf ( \\\" Solution ▁ does ▁ not ▁ exist \\\" ) ; return 0 ; } else printSolution ( sol ) ; return 1 ; } int solveKTUtil ( int x , int y , int movei , int sol [ N ] [ N ] , int xMove [ N ] , int yMove [ N ] ) { int k , next_x , next_y ; if ( movei == N * N ) return 1 ; for ( k = 0 ; k < 8 ; k ++ ) { next_x = x + xMove [ k ] ; next_y = y + yMove [ k ] ; if ( isSafe ( next_x , next_y , sol ) ) { sol [ next_x ] [ next_y ] = movei ; if ( solveKTUtil ( next_x , next_y , movei + 1 , sol , xMove , yMove ) == 1 ) return 1 ; else sol [ next_x ] [ next_y ] = -1 ; } } return 0 ; } int main ( ) { solveKT ( ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Selection Sort | C program for implementation of selection sort ; swap function ; sort function ; One by one move boundary of unsorted subarray ; Find the minimum element in unsorted array ; Swap the found minimum element with the first element ; Function to print an array ; Driver program to test above functions\\\"\\nSolution in C:\",\"targets\":\"#include \\nvoid swap ( int * xp , int * yp ) { int temp = * xp ; * xp = * yp ; * yp = temp ; } void selectionSort ( int arr [ ] , int n ) { int i , j , min_idx ; for ( i = 0 ; i < n - 1 ; i ++ ) { min_idx = i ; for ( j = i + 1 ; j < n ; j ++ ) if ( arr [ j ] < arr [ min_idx ] ) min_idx = j ; swap ( & arr [ min_idx ] , & arr [ i ] ) ; } } void printArray ( int arr [ ] , int size ) { int i ; for ( i = 0 ; i < size ; i ++ ) printf ( \\\" % d ▁ \\\" , arr [ i ] ) ; printf ( \\\" \\n \\\" ) ; } int main ( ) { int arr [ ] = { 64 , 25 , 12 , 22 , 11 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; selectionSort ( arr , n ) ; printf ( \\\" Sorted ▁ array : ▁ \\n \\\" ) ; printArray ( arr , n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Maximum String Partition | Return the count of string ; P will store the answer ; Current will store current string Previous will store the previous string that has been taken already ; Add a character to current string ; Here we will create a partition and update the previous string with current string ; Now we will clear the current string ; Increment the count of partition . ; Driver code\\\"\\nSolution in Javascript:\",\"targets\":\"function maxPartition ( s ) { var n = s . length , P = 0 ; var current = \\\" \\\" , previous = \\\" \\\" ; for ( var i = 0 ; i < n ; i ++ ) { current += s [ i ] ; if ( current != previous ) { previous = current ; current = \\\" \\\" ; P ++ ; } } return P ; } var s = \\\" \\\" ; var ans = maxPartition ( s ) ; document . write ( ans ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Count numbers with unit digit k in given range | Returns count of numbers with k as last digit . ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function counLastDigitK ( $ low , $ high , $ k ) { $ count = 0 ; for ( $ i = $ low ; $ i <= $ high ; $ i ++ ) if ( $ i % 10 == $ k ) $ count ++ ; return $ count ; } $ low = 3 ; $ high = 35 ; $ k = 3 ; echo counLastDigitK ( $ low , $ high , $ k ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"String containing first letter of every word in a given string with spaces | Function to find string which has first character of each word . ; Traverse the string . ; If it is space , set v as true . ; Else check if v is true or not . If true , copy character in output string and set v as false . ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def firstLetterWord ( str ) :\\n\\tresult = \\\" \\\"\\n\\tv = True\\n\\tfor i in range ( len ( str ) ) :\\n\\t\\tif ( str [ i ] == ' ▁ ' ) :\\n\\t\\t\\tv = True\\n\\t\\telif ( str [ i ] != ' ▁ ' and v == True ) :\\n\\t\\t\\tresult += ( str [ i ] )\\n\\t\\t\\tv = False\\n\\treturn result\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tstr = \\\" geeks ▁ for ▁ geeks \\\"\\n\\tprint ( firstLetterWord ( str ) )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Largest area square in an array when elements can be shuffled | C # implementation of the approach ; Function that returns true if it is possible to make a square with side equal to l ; To store the count of elements greater than or equal to l ; Increment the count ; If the count becomes greater than or equal to l ; Function to return the maximum area of the square that can be obtained ; If square is possible with side length m ; Try to find a square with smaller side length ; Return the area ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static bool isSquarePossible ( int [ ] arr , int n , int l ) { int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] >= l ) cnt ++ ; if ( cnt >= l ) return true ; } return false ; } static int maxArea ( int [ ] arr , int n ) { int l = 0 , r = n ; int len = 0 ; while ( l <= r ) { int m = l + ( ( r - l ) \\/ 2 ) ; if ( isSquarePossible ( arr , n , m ) ) { len = m ; l = m + 1 ; } else r = m - 1 ; } return ( len * len ) ; } public static void Main ( ) { int [ ] arr = { 1 , 3 , 4 , 5 , 5 } ; int n = arr . Length ; Console . WriteLine ( maxArea ( arr , n ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Find minimum positive integer x such that a ( x ^ 2 ) + b ( x ) + c >= k | Function to return the minimum positive integer satisfying the given equation ; Binary search to find the value of x ; Return the answer ; Driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function MinimumX ( a , b , c , k ) { let x = Number . MAX_VALUE ; if ( k <= c ) return 0 ; let h = k - c ; let l = 0 ; while ( l <= h ) { let m = Math . floor ( ( l + h ) \\/ 2 ) ; if ( ( a * m * m ) + ( b * m ) > ( k - c ) ) { x = Math . min ( x , m ) ; h = m - 1 ; } else if ( ( a * m * m ) + ( b * m ) < ( k - c ) ) l = m + 1 ; else return m ; } return x ; } let a = 3 , b = 2 , c = 4 , k = 15 ; document . write ( MinimumX ( a , b , c , k ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Divide array into increasing and decreasing subsequence without changing the order | Function to print strictly increasing and strictly decreasing sequence if possible ; Arrays to store strictly increasing and decreasing sequence ; Initializing last element of both sequence ; Iterating through the array ; If current element can be appended to both the sequences ; If next element is greater than the current element Then append it to the strictly increasing array ; Otherwise append it to the strictly decreasing array ; If current element can be appended to the increasing sequence only ; If current element can be appended to the decreasing sequence only ; Else we can not make such sequences from the given array ; Print the required sequences ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function Find_Sequence ( $ arr , $ n ) { $ inc_arr = array ( ) ; $ dec_arr = array ( ) ; $ inc = -1 ; $ dec = 1e7 ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { if ( $ inc < $ arr [ $ i ] && $ arr [ $ i ] < $ dec ) { if ( $ arr [ $ i ] < $ arr [ $ i + 1 ] ) { $ inc = $ arr [ $ i ] ; array_push ( $ inc_arr , $ arr [ $ i ] ) ; } else { $ dec = $ arr [ $ i ] ; array_push ( $ dec_arr , $ arr [ $ i ] ) ; } } else if ( $ inc < $ arr [ $ i ] ) { $ inc = $ arr [ $ i ] ; array_push ( $ inc_arr , $ arr [ $ i ] ) ; } else if ( $ dec > $ arr [ $ i ] ) { $ dec = $ arr [ $ i ] ; array_push ( $ dec_arr , $ arr [ $ i ] ) ; } else { echo ' - 1' ; break ; } } print_r ( $ inc_arr ) ; print_r ( $ dec_arr ) ; } $ arr = array ( 5 , 1 , 3 , 6 , 8 , 2 , 9 , 0 , 10 ) ; $ n = count ( $ arr ) ; Find_Sequence ( $ arr , $ n ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Smallest power of 4 greater than or equal to N | C # implementation of above approach ; Function to return the smallest power of 4 greater than or equal to n ; If n is itself is a power of 4 then return n ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static int nextPowerOfFour ( int n ) { int x = ( int ) Math . Floor ( Math . Sqrt ( Math . Sqrt ( n ) ) ) ; if ( Math . Pow ( x , 4 ) == n ) return n ; else { x = x + 1 ; return ( int ) Math . Pow ( x , 4 ) ; } } public static void Main ( ) { int n = 122 ; Console . WriteLine ( nextPowerOfFour ( n ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Count of integers of length N and value less than K such that they contain digits only from the given set | Java implementation of the approach ; Function to convert a number into vector ; Push all the digits of N from the end one by one to the vector ; If the original number was 0 ; Reverse the vector elements ; Return the required vector ; Function to return the count of B length integers which are less than C and they contain digits from set A [ ] only ; Convert number to digit array ; Case 1 : No such number possible as the generated numbers will always be greater than C ; Case 2 : All integers of length B are valid as they all are less than C ; contain 0 ; Case 3 ; Update the lower [ ] array such that lower [ i ] stores the count of elements in A [ ] which are less than i ; For first index we can 't use 0 ; Whether ( i - 1 ) digit of generated number can be equal to ( i - 1 ) digit of C ; Is digit [ i - 1 ] present in A ? ; Driver code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { static int MAX = 10 ; static Vector < Integer > numToVec ( int N ) { Vector < Integer > digit = new Vector < Integer > ( ) ; while ( N != 0 ) { digit . add ( N % 10 ) ; N = N \\/ 10 ; } if ( digit . size ( ) == 0 ) digit . add ( 0 ) ; Collections . reverse ( digit ) ; return digit ; } static int solve ( Vector < Integer > A , int B , int C ) { Vector < Integer > digit = new Vector < Integer > ( ) ; int d , d2 ; digit = numToVec ( C ) ; d = A . size ( ) ; if ( B > digit . size ( ) d == 0 ) return 0 ; else if ( B < digit . size ( ) ) { if ( A . get ( 0 ) == 0 && B != 1 ) return ( int ) ( ( d - 1 ) * Math . pow ( d , B - 1 ) ) ; else return ( int ) Math . pow ( d , B ) ; } else { int [ ] dp = new int [ B + 1 ] ; int [ ] lower = new int [ MAX + 1 ] ; for ( int i = 0 ; i < d ; i ++ ) lower [ A . get ( i ) + 1 ] = 1 ; for ( int i = 1 ; i <= MAX ; i ++ ) lower [ i ] = lower [ i - 1 ] + lower [ i ] ; boolean flag = true ; dp [ 0 ] = 0 ; for ( int i = 1 ; i <= B ; i ++ ) { d2 = lower [ digit . get ( i - 1 ) ] ; dp [ i ] = dp [ i - 1 ] * d ; if ( i == 1 && A . get ( 0 ) == 0 && B != 1 ) d2 = d2 - 1 ; if ( flag ) dp [ i ] += d2 ; flag = ( flag & ( lower [ digit . get ( i - 1 ) + 1 ] == lower [ digit . get ( i - 1 ) ] + 1 ) ) ; } return dp [ B ] ; } } public static void main ( String [ ] args ) { Integer arr [ ] = { 0 , 1 , 2 , 5 } ; Vector < Integer > A = new Vector < > ( Arrays . asList ( arr ) ) ; int N = 2 ; int k = 21 ; System . out . println ( solve ( A , N , k ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Search an element in a Linked List ( Iterative and Recursive ) | Recursive C program to search an element in linked list ; Link list node ; Given a reference ( pointer to pointer ) to the head of a list and an int , push a new node on the front of the list . ; allocate node put in the key ; link the old list off the new node ; move the head to point to the new node ; Checks whether the value x is present in linked list ; Base case ; If key is present in current node , return true ; Recur for remaining list ; Driver program to test count function ; Start with the empty list ; Use push ( ) to construct below list 14 -> 21 -> 11 -> 30 -> 10\\\"\\nSolution in C:\",\"targets\":\"#include \\n#include \\n#include \\nstruct Node { int key ; struct Node * next ; } ; void push ( struct Node * * head_ref , int new_key ) { struct Node * new_node = ( struct Node * ) malloc ( sizeof ( struct Node ) ) ; new_node -> key = new_key ; new_node -> next = ( * head_ref ) ; ( * head_ref ) = new_node ; } bool search ( struct Node * head , int x ) { if ( head == NULL ) return false ; if ( head -> key == x ) return true ; return search ( head -> next , x ) ; } int main ( ) { struct Node * head = NULL ; int x = 21 ; push ( & head , 10 ) ; push ( & head , 30 ) ; push ( & head , 11 ) ; push ( & head , 21 ) ; push ( & head , 14 ) ; search ( head , 21 ) ? printf ( \\\" Yes \\\" ) : printf ( \\\" No \\\" ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Check if any permutation of string is a K times repeated string | C # implementation to check that the permutation of the given String is K times repeated String ; Function to check that permutation of the given String is a K times repeating String ; if length of String is not divisible by K ; Frequency Array ; Initially frequency of each character is 0 ; Computing the frequency of each character in the String ; Loop to check that frequency of every character of the String is divisible by K ; Driver Code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static bool repeatingString ( String s , int n , int k ) { if ( n % k != 0 ) { return false ; } int [ ] frequency = new int [ 123 ] ; for ( int i = 0 ; i < 123 ; i ++ ) { frequency [ i ] = 0 ; } for ( int i = 0 ; i < n ; i ++ ) { frequency [ s [ i ] ] ++ ; } int repeat = n \\/ k ; for ( int i = 0 ; i < 123 ; i ++ ) { if ( frequency [ i ] % repeat != 0 ) { return false ; } } return true ; } public static void Main ( String [ ] args ) { String s = \\\" abcdcba \\\" ; int n = s . Length ; int k = 3 ; if ( repeatingString ( s , n , k ) ) { Console . Write ( \\\" Yes \\\" + \\\" \\n \\\" ) ; } else { Console . Write ( \\\" No \\\" + \\\" \\n \\\" ) ; } } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Ways to place 4 items in n ^ 2 positions such that no row \\/ column contains more than one | C # implementation of the approach ; Function to return the number of ways to place 4 items in n ^ 2 positions ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { public static long NumberofWays ( int n ) { long x = ( 1l * ( n ) * ( n - 1 ) * ( n - 2 ) * ( n - 3 ) ) \\/ ( 4 * 3 * 2 * 1 ) ; long y = ( 1l * ( n ) * ( n - 1 ) * ( n - 2 ) * ( n - 3 ) ) ; return ( 1l * x * y ) ; } public static void Main ( string [ ] args ) { int n = 4 ; Console . WriteLine ( NumberofWays ( n ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Program to check if input is an integer or a string | Returns true if s is a number else false ; Saving the input in a string ; Function returns 1 if all elements are in range '0-9' ; Function returns 0 if the input is not an integer\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function isNumber ( $ s ) { for ( $ i = 0 ; $ i < strlen ( $ s ) ; $ i ++ ) if ( is_numeric ( $ s [ $ i ] ) == false ) return false ; return true ; } $ str = \\\"6790\\\" ; if ( isNumber ( $ str ) ) echo \\\" Integer \\\" ; else echo \\\" String \\\" ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Program to find the length of Latus Rectum of a Hyperbola | Function to calculate the length of the latus rectum of a hyperbola ; Store the length of major axis ; Store the length of minor axis ; Store the length of the latus rectum ; Return the length of the latus rectum ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"def lengthOfLatusRectum ( A , B ) :\\n\\tmajor = 2.0 * A\\n\\tminor = 2.0 * B\\n\\tlatus_rectum = ( minor * minor ) \\/ major\\n\\treturn latus_rectum\\nA = 3.0\\nB = 2.0\\nprint ( round ( lengthOfLatusRectum ( A , B ) , 5 ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Number of ways to split a binary number such that every part is divisible by 2 | Javascript implementation of the approach ; Function to return the required count ; If the splitting is not possible ; To store the count of zeroes ; Counting the number of zeroes ; Return the final answer ; Driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"var maxN = 20 ; var maxM = 64 ; function cntSplits ( s ) { if ( s [ s . length - 1 ] == ' ' ) return 0 ; var c_zero = 0 ; for ( var i = 0 ; i < s . length ; i ++ ) c_zero += ( s [ i ] == ' ' ) ; return Math . pow ( 2 , c_zero - 1 ) ; } var s = \\\" \\\" ; document . write ( cntSplits ( s ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"d | C ++ program to find the size of the minimum dominating set of the tree ; Definition of a tree node ; Helper function that allocates a new node ; DP array to precompute and store the results ; minDominatingSettion to return the size of the minimum dominating set of the array ; Base case ; Setting the compulsory value if needed ; Check if the answer is already computed ; If it is compulsory to select the node ; Choose the node and set its children as covered ; If it is covered ; If the current node is neither covered nor needs to be selected compulsorily ; Store the result ; Driver code ; initialising the DP array ; Constructing the tree\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; #define N 1005\\nstruct Node { int data ; Node * left , * right ; } ; Node * newNode ( int data ) { Node * node = new Node ( ) ; node -> data = data ; node -> left = node -> right = NULL ; return node ; } int dp [ N ] [ 5 ] [ 5 ] ; int minDominatingSet ( Node * root , int covered , int compulsory ) { if ( ! root ) return 0 ; if ( ! root -> left and ! root -> right and ! covered ) compulsory = true ; if ( dp [ root -> data ] [ covered ] [ compulsory ] != -1 ) return dp [ root -> data ] [ covered ] [ compulsory ] ; if ( compulsory ) { return dp [ root -> data ] [ covered ] [ compulsory ] = 1 + minDominatingSet ( root -> left , 1 , 0 ) + minDominatingSet ( root -> right , 1 , 0 ) ; } if ( covered ) { return dp [ root -> data ] [ covered ] [ compulsory ] = min ( 1 + minDominatingSet ( root -> left , 1 , 0 ) + minDominatingSet ( root -> right , 1 , 0 ) , minDominatingSet ( root -> left , 0 , 0 ) + minDominatingSet ( root -> right , 0 , 0 ) ) ; } int ans = 1 + minDominatingSet ( root -> left , 1 , 0 ) + minDominatingSet ( root -> right , 1 , 0 ) ; if ( root -> left ) { ans = min ( ans , minDominatingSet ( root -> left , 0 , 1 ) + minDominatingSet ( root -> right , 0 , 0 ) ) ; } if ( root -> right ) { ans = min ( ans , minDominatingSet ( root -> left , 0 , 0 ) + minDominatingSet ( root -> right , 0 , 1 ) ) ; } return dp [ root -> data ] [ covered ] [ compulsory ] = ans ; } signed main ( ) { memset ( dp , -1 , sizeof ( dp ) ) ; Node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> left -> left = newNode ( 3 ) ; root -> left -> right = newNode ( 4 ) ; root -> left -> left -> left = newNode ( 5 ) ; root -> left -> left -> left -> left = newNode ( 6 ) ; root -> left -> left -> left -> right = newNode ( 7 ) ; root -> left -> left -> left -> right -> right = newNode ( 10 ) ; root -> left -> left -> left -> left -> left = newNode ( 8 ) ; root -> left -> left -> left -> left -> right = newNode ( 9 ) ; cout << minDominatingSet ( root , 0 , 0 ) << endl ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Arc length from given Angle | function to calculate arc length ; Driver Code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function arcLength ( diameter , angle ) { let pi = 22.0 \\/ 7.0 ; let arc ; if ( angle >= 360 ) { document . write ( \\\" \\\" + \\\" \\\" ) ; return 0 ; } else { arc = ( pi * diameter ) * ( angle \\/ 360.0 ) ; return arc ; } } let diameter = 25.0 ; let angle = 45.0 ; let arc_len = arcLength ( diameter , angle ) ; document . write ( arc_len ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Largest gap in an array | A C program to find largest gap between two elements in an array . ; function to solve the given problem ; finding maximum and minimum of an array ; Driver Code\\\"\\nSolution in C:\",\"targets\":\"#include \\n#include \\n#include \\nint solve ( int a [ ] , int n ) { int min1 = a [ 0 ] ; int max1 = a [ 0 ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] > max1 ) max1 = a [ i ] ; if ( a [ i ] < min1 ) min1 = a [ i ] ; } return abs ( min1 - max1 ) ; } int main ( ) { int arr [ ] = { -1 , 2 , 3 , 4 , -10 } ; int size = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; printf ( \\\" Largest ▁ gap ▁ is ▁ : ▁ % d \\\" , solve ( arr , size ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"Print all possible combinations of r elements in a given array of size n | Program to print all combination of size r in an array of size n ; The main function that prints all combinations of size r in arr [ ] of size n . This function mainly uses combinationUtil ( ) ; A temporary array to store all combination one by one ; Print all combination using temprary array ' data [ ] ' ; arr [ ] -- -> Input Array n -- -> Size of input array r -- -> Size of a combination to be printed index -- -> Current index in data [ ] data [ ] -- -> Temporary array to store current combination i -- -> index of current element in arr [ ] ; Current cobination is ready , print it ; When no more elements are there to put in data [ ] ; current is included , put next at next location ; current is excluded , replace it with next ( Note that i + 1 is passed , but index is not changed ) ; Driver program to test above functions\\nHow can the above be solved in C?\",\"targets\":\"#include \\nvoid combinationUtil ( int arr [ ] , int n , int r , int index , int data [ ] , int i ) ; void printCombination ( int arr [ ] , int n , int r ) { int data [ r ] ; combinationUtil ( arr , n , r , 0 , data , 0 ) ; } void combinationUtil ( int arr [ ] , int n , int r , int index , int data [ ] , int i ) { if ( index == r ) { for ( int j = 0 ; j < r ; j ++ ) printf ( \\\" % d ▁ \\\" , data [ j ] ) ; printf ( \\\" \\n \\\" ) ; return ; } if ( i >= n ) return ; data [ index ] = arr [ i ] ; combinationUtil ( arr , n , r , index + 1 , data , i + 1 ) ; combinationUtil ( arr , n , r , index , data , i + 1 ) ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int r = 3 ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; printCombination ( arr , n , r ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Minimum number of given operations required to reduce the array to 0 element | Function to return the minimum operations required ; Count the frequency of each element ; Maximum element from the array ; Find all the multiples of i ; Delete the multiples ; Increment the operations ; Driver code\\\"\\nSolution in php:\",\"targets\":\"< ? php function minOperations ( $ arr , $ n ) { $ result = 0 ; $ freq = array ( ) ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { $ freq [ $ arr [ $ i ] ] = 0 ; } for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { $ x = $ arr [ $ i ] ; $ freq [ $ x ] ++ ; } $ maxi = max ( $ arr ) ; for ( $ i = 1 ; $ i <= $ maxi ; $ i ++ ) { if ( $ freq [ $ i ] != 0 ) { for ( $ j = $ i * 2 ; $ j <= $ maxi ; $ j = $ j + $ i ) { $ freq [ $ j ] = 0 ; } $ result ++ ; } } return $ result ; } $ arr = array ( 2 , 4 , 2 , 4 , 4 , 4 ) ; $ n = count ( $ arr ) ; echo minOperations ( $ arr , $ n ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Program to print non square numbers | CPP program to print first n non square number ; Returns n - th non - square number . ; loop to print non squares below n ; Driver code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nint nonsquare ( int n ) { return n + ( int ) ( 0.5 + sqrt ( n ) ) ; } void printNonSquare ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) printf ( \\\" % d ▁ \\\" , nonsquare ( i ) ) ; } int main ( ) { int n = 10 ; printNonSquare ( n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Check if given string is a substring of string formed by repeated concatenation of z to a | Function checks if a given string is valid or not and prints the output ; Boolean flag variable to mark if given string is valid ; Traverse the given string ; If adjacent character differ by 1 ; If character ' a ' is followed by 4 ; Else flip the flag and break from the loop ; Output according to flag variable ; Given string ; Function Call\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function checkInfinite ( s ) { var flag = 1 ; var N = s . length ; for ( var i = 0 ; i < N - 1 ; i ++ ) { if ( s [ i ] == String . fromCharCode ( ( s [ i + 1 ] . charCodeAt ( 0 ) ) + 1 ) ) { continue ; } else if ( s [ i ] == ' ' && s [ i + 1 ] == ' ' ) { continue ; } else { flag = 0 ; break ; } } if ( flag == 0 ) document . write ( \\\" \\\" ) ; else document . write ( \\\" \\\" ) ; } var s = \\\" \\\" ; checkInfinite ( s ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Primality Test | Set 5 ( Using Lucas | Function to find out first n terms ( considering 4 as 0 th term ) of Lucas - Lehmer series . ; the 0 th term of the series is 4. ; create an array to store the terms . ; compute each term and add it to the array . ; print out the terms one by one . ; Driver Code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function LucasLehmer ( n ) { let current_val = 4 ; let series = [ ] ; series . push ( current_val ) ; for ( let i = 0 ; i < n ; i ++ ) { current_val = ( current_val * current_val ) - 2 ; series . push ( current_val ) ; } for ( let i = 0 ; i <= n ; i ++ ) { document . write ( \\\" \\\" + i + \\\" \\\" + series [ i ] + \\\" \\\" ) ; } } let n = 5 ; LucasLehmer ( n ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Check if lowercase and uppercase characters are in same order | Function to check if both the case follow the same order ; Traverse the string ; Store both lowercase and uppercase in two different strings ; transfor lowerStr to uppercase ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def isCheck ( str ) :\\n\\tlength = len ( str )\\n\\tlowerStr , upperStr = \\\" \\\" , \\\" \\\"\\n\\tfor i in range ( length ) :\\n\\t\\tif ( ord ( str [ i ] ) >= 65 and ord ( str [ i ] ) <= 91 ) :\\n\\t\\t\\tupperStr = upperStr + str [ i ]\\n\\t\\telse :\\n\\t\\t\\tlowerStr = lowerStr + str [ i ]\\n\\ttransformStr = lowerStr . upper ( )\\n\\treturn transformStr == upperStr\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tstr = \\\" geeGkEEsKS \\\"\\n\\tif isCheck ( str ) :\\n\\t\\tprint ( \\\" Yes \\\" )\\n\\telse :\\n\\t\\tprint ( \\\" No \\\" )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Print characters having prime frequencies in order of occurrence | C # code for the above approach ; Function to check primes ; Counting the frequency of all character using Counter function ; Traversing string ; Driver code ; Passing string to checkString function\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; using System . Collections . Generic ; class GFG { static bool prime ( int n ) { if ( n <= 1 ) return false ; int max_div = ( int ) Math . Floor ( Math . Sqrt ( n ) ) ; for ( int i = 2 ; i < 1 + max_div ; i ++ ) { if ( n % i == 0 ) return false ; } return true ; } static void checkString ( string s ) { Dictionary < char , int > freq = new Dictionary < char , int > ( ) ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( ! freq . ContainsKey ( s [ i ] ) ) freq [ s [ i ] ] = 0 ; freq [ s [ i ] ] += 1 ; } for ( int i = 0 ; i < s . Length ; i ++ ) { if ( prime ( freq [ s [ i ] ] ) ) Console . Write ( s [ i ] ) ; } } public static void Main ( ) { string s = \\\" geeksforgeeks \\\" ; checkString ( s ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Find the Alpha Score of the Given Steps ( Using BST ) | Structure of a node ; Function to calculate and return the Alpha Score of the journey ; Traverse left subtree ; Calculate the alpha score of the current step ; Update alpha score of the journey ; Traverse right subtree ; Return ; Function to construct a BST from the sorted array [ ] arr ; Insert root ; Construct left subtree ; Construct right subtree ; Return root ; Driver Code ; Sort the array ; Construct BST from the sorted array\\\"\\nSolution in Javascript:\",\"targets\":\"class Node { constructor ( data ) { this . data = data ; this . left = null ; this . right = null ; } } var root = null ; function AlphaScore ( ) { root = null ; } var sum = 0 , total_sum = 0 ; var mod = 1000000007 ; function getAlphaScore ( node ) { if ( node . left != null ) getAlphaScore ( node . left ) ; sum = ( sum + node . data ) % mod ; total_sum = ( total_sum + sum ) % mod ; if ( node . right != null ) getAlphaScore ( node . right ) ; return total_sum ; } function constructBST ( arr , start , end , root ) { if ( start > end ) return null ; var mid = parseInt ( ( start + end ) \\/ 2 ) ; if ( root == null ) root = new Node ( arr [ mid ] ) ; root . left = constructBST ( arr , start , mid - 1 , root . left ) ; root . right = constructBST ( arr , mid + 1 , end , root . right ) ; return root ; } var arr = [ 10 , 11 , 12 ] ; var length = arr . length ; arr . sort ( ) ; var root = null ; root = constructBST ( arr , 0 , length - 1 , root ) ; document . write ( getAlphaScore ( root ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Find Prime number just less than and just greater each element of given Array | C ++ program for the above approach ; Utility function to check for primality of a number X by checking whether X haACCs any factors other than 1 and itself . ; if ( X % i == 0 ) Factor found ; Function to print primes just less than and just greater than of each element in an array ; Traverse the array ; Traverse for finding prime just less than A [ i ] ; Prime just less than A [ i ] found ; Traverse for finding prime just greater than A [ i ] ; Prime just greater than A [ i ] found ; Driver code ; Input ; Function call\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; bool isPrime ( int X ) { for ( int i = 2 ; i * i <= X ; i ++ ) return false ; return true ; } void printPrimes ( int A [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = A [ i ] - 1 ; ; j -- ) { if ( isPrime ( j ) ) { cout << j << \\\" ▁ \\\" ; break ; } } for ( int j = A [ i ] + 1 ; ; j ++ ) { if ( isPrime ( j ) ) { cout << j << \\\" ▁ \\\" ; break ; } } cout << endl ; } } int main ( ) { int A [ ] = { 17 , 28 } ; int N = sizeof ( A ) \\/ sizeof ( A [ 0 ] ) ; printPrimes ( A , N ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Biggest Square that can be inscribed within an Equilateral triangle | Function to find the side of the square ; the side cannot be negative ; side of the square ; Driver code\\\"\\nSolution in php:\",\"targets\":\"< ? php function square ( $ a ) { if ( $ a < 0 ) return -1 ; $ x = 0.464 * $ a ; return $ x ; } $ a = 5 ; echo square ( $ a ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Check if given string is a substring of string formed by repeated concatenation of z to a | C ++ program for the above approach ; Function checks if a given string is valid or not and prints the output ; Boolean flag variable to mark if given string is valid ; Traverse the given string ; If adjacent character differ by 1 ; If character ' a ' is followed by 4 ; Else flip the flag and break from the loop ; Output according to flag variable ; Driver Code ; Given string ; Function Call\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; void checkInfinite ( string s ) { bool flag = 1 ; int N = s . length ( ) ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( s [ i ] == char ( int ( s [ i + 1 ] ) + 1 ) ) { continue ; } else if ( s [ i ] == ' a ' && s [ i + 1 ] == ' z ' ) { continue ; } else { flag = 0 ; break ; } } if ( flag == 0 ) cout << \\\" NO \\\" ; else cout << \\\" YES \\\" ; } int main ( ) { string s = \\\" ecbaz \\\" ; checkInfinite ( s ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"Count set bits in an integer | ; Check each bit in a number is set or not and return the total count of the set bits . ; ( 1 << i ) = pow ( 2 , i ) ; Driver Code\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint countSetBits ( int N ) { int count = 0 ; for ( int i = 0 ; i < sizeof ( int ) * 8 ; i ++ ) { if ( N & ( 1 << i ) ) count ++ ; } return count ; } int main ( ) { int N = 15 ; printf ( \\\" % d \\\" , countSetBits ( N ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Split a given string into substrings of length K with equal sum of ASCII values | Function for checking string ; Check if the string can be split into substrings of K length only ; Compute the sum of first substring of length K ; Compute the sum of remaining substrings ; Check if sum is equal to that of the first substring ; Since all sums are not equal , return false ; All sums are equal , Return true ; All substrings cannot be of size K ; Driver code\\\"\\nSolution in Javascript:\",\"targets\":\"function check ( str , K ) { if ( str . length % K === 0 ) { var sum = 0 , i ; for ( i = 0 ; i < K ; i ++ ) { sum += str [ i ] . charCodeAt ( 0 ) ; } for ( var j = i ; j < str . length ; j += K ) { var s_comp = 0 ; for ( var p = j ; p < j + K ; p ++ ) s_comp += str [ p ] . charCodeAt ( 0 ) ; if ( s_comp !== sum ) return false ; } return true ; } return false ; } var K = 3 ; var str = \\\" \\\" ; if ( check ( str , K ) ) document . write ( \\\" \\\" ) ; else document . write ( \\\" \\\" ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Minimum , maximum and average price values for all the items of given type | Java implementation of the approach ; To store an item ; To store the minimum and the maximum price for the item ; To store the total number of items of the current type and the total cost of buying them ; Initializing an element ; Function to find the minimum , the maximum and the average price for every item ; To store the distinct items ; For every item ; If the current item has aready been purchased earlier from a different shop ; Get the item ; Update its minimum and maximum price so far ; Increment the total count of the current item ; Add the current price to the sum ; The item has been purchased for the first time ; Print all the items with their minimum , maximum and average prices ; Driver code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { static class Item { int min , max ; int total , sum ; Item ( int price ) { min = price ; max = price ; total = 1 ; this . sum = price ; } } static void findPrices ( String item [ ] , int price [ ] , int n ) { HashMap < String , Item > map = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( map . containsKey ( item [ i ] ) ) { Item currItem = map . get ( item [ i ] ) ; currItem . min = Math . min ( currItem . min , price [ i ] ) ; currItem . max = Math . max ( currItem . max , price [ i ] ) ; currItem . total ++ ; currItem . sum += price [ i ] ; } else { Item currItem = new Item ( price [ i ] ) ; map . put ( item [ i ] , currItem ) ; } } System . out . println ( \\\" Item ▁ Min ▁ Max ▁ Average \\\" ) ; for ( Map . Entry < String , Item > ob : map . entrySet ( ) ) { String key = ob . getKey ( ) ; Item currItem = ob . getValue ( ) ; System . out . println ( key + \\\" ▁ \\\" + currItem . min + \\\" ▁ \\\" + currItem . max + \\\" ▁ \\\" + ( ( float ) currItem . sum \\/ ( float ) currItem . total ) ) ; } } public static void main ( String args [ ] ) { String item [ ] = { \\\" toy \\\" , \\\" pen \\\" , \\\" notebook \\\" , \\\" pen \\\" } ; int n = item . length ; int price [ ] = { 2 , 1 , 3 , 2 } ; findPrices ( item , price , n ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Check if a number exists having exactly N factors and K prime factors | Function to compute the number of factors of the given number ; Vector to store the prime factors ; While there are no two multiples in the number , divide it by 2 ; If the size is already greater than K , then return true ; Computing the remaining divisors of the number ; If n is divisible by i , then it is a divisor ; If the size is already greater than K , then return true ; If the size is already greater than K , then return true ; If none of the above conditions satisfies , then return false ; Function to check if it is possible to make a number having total N factors and K prime factors ; If total divisors are less than the number of prime divisors , then print No ; Find the number of factors of n ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"def factors ( n , k ) :\\n\\tv = [ ] ;\\n\\twhile ( n % 2 == 0 ) :\\n\\t\\tv . append ( 2 ) ;\\n\\t\\tn \\/\\/= 2 ;\\n\\tif ( len ( v ) >= k ) :\\n\\t\\treturn True ;\\n\\tfor i in range ( 3 , int ( n ** ( 1 \\/ 2 ) ) , 2 ) :\\n\\t\\twhile ( n % i == 0 ) :\\n\\t\\t\\tn = n \\/\\/ i ;\\n\\t\\t\\tv . append ( i ) ;\\n\\t\\tif ( len ( v ) >= k ) :\\n\\t\\t\\treturn True ;\\n\\tif ( n > 2 ) :\\n\\t\\tv . append ( n ) ;\\n\\tif ( len ( v ) >= k ) :\\n\\t\\treturn True ;\\n\\treturn False ;\\ndef operation ( n , k ) :\\n\\tanswered = False ;\\n\\tif ( n < k ) :\\n\\t\\tanswered = True ;\\n\\t\\tprint ( \\\" No \\\" ) ;\\n\\tok = factors ( n , k ) ;\\n\\tif ( not ok and not answered ) :\\n\\t\\tanswered = True ;\\n\\t\\tprint ( \\\" No \\\" ) ;\\n\\tif ( ok and not answered ) :\\n\\t\\tprint ( \\\" Yes \\\" ) ;\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tn = 4 ;\\n\\tk = 2 ;\\n\\toperation ( n , k ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Program for Goldbachâ €™ s Conjecture ( Two Primes with given Sum ) | PHP program to implement Goldbach 's conjecture ; Array to store all prime less than and equal to 10 ^ 6 ; Utility function for Sieve of Sundaram ; In general Sieve of Sundaram , produces primes smaller than ( 2 * x + 2 ) for a number given number x . Since we want primes smaller than MAX , we reduce MAX to half . This array is used to separate numbers of the form i + j + 2 * i * j from others where 1 <= i <= j ; Main logic of Sundaram . Mark all numbers which do not generate prime number by doing 2 * i + 1 ; Since 2 is a prime number ; Print other primes . Remaining primes are of the form 2 * i + 1 such that marked [ i ] is false . ; Function to perform Goldbach 's conjecture ; Return if number is not even or less than 3 ; Check only upto half of number ; find difference by subtracting current prime from n ; Search if the difference is also a prime number ; Express as a sum of primes ; Finding all prime numbers before limit ; Express number as a sum of two primes\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php $ MAX = 10000 ; $ primes = array ( ) ; function sieveSundaram ( ) { global $ MAX , $ primes ; $ marked = array_fill ( 0 , ( int ) ( $ MAX \\/ 2 ) + 100 , false ) ; for ( $ i = 1 ; $ i <= ( sqrt ( $ MAX ) - 1 ) \\/ 2 ; $ i ++ ) for ( $ j = ( $ i * ( $ i + 1 ) ) << 1 ; $ j <= $ MAX \\/ 2 ; $ j = $ j + 2 * $ i + 1 ) $ marked [ $ j ] = true ; array_push ( $ primes , 2 ) ; for ( $ i = 1 ; $ i <= $ MAX \\/ 2 ; $ i ++ ) if ( $ marked [ $ i ] == false ) array_push ( $ primes , 2 * $ i + 1 ) ; } function findPrimes ( $ n ) { global $ MAX , $ primes ; if ( $ n <= 2 $ n % 2 != 0 ) { print ( \\\" Invalid ▁ Input ▁ \\n \\\" ) ; return ; } for ( $ i = 0 ; $ primes [ $ i ] <= $ n \\/ 2 ; $ i ++ ) { $ diff = $ n - $ primes [ $ i ] ; if ( in_array ( $ diff , $ primes ) ) { print ( $ primes [ $ i ] . \\\" + \\\" ▁ . ▁ $ diff ▁ . ▁ \\\" = \\\" ▁ . ▁ $ n ▁ . ▁ \\\" \\\" return ; } } } sieveSundaram ( ) ; findPrimes ( 4 ) ; findPrimes ( 38 ) ; findPrimes ( 100 ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Find the smallest number X such that X ! contains at least Y trailing zeros . | Function to count the number of factors P in X ! ; Function to find the smallest X such that X ! contains Y trailing zeros ; Driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function countFactor ( P , X ) { if ( X < P ) return 0 ; return ( parseInt ( X \\/ P ) + countFactor ( P , parseInt ( X \\/ P ) ) ) ; } function findSmallestX ( Y ) { let low = 0 , high = 5 * Y ; let N = 0 ; while ( low <= high ) { let mid = parseInt ( ( high + low ) \\/ 2 ) ; if ( countFactor ( 5 , mid ) < Y ) { low = mid + 1 ; } else { N = mid ; high = mid - 1 ; } } return N ; } let Y = 10 ; document . write ( findSmallestX ( Y ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Number of loops of size k starting from a specific node | Return the Number of ways from a node to make a loop of size K in undirected complete connected graph of N nodes ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function numOfways ( $ n , $ k ) { $ p = 1 ; if ( $ k % 2 ) $ p = -1 ; return ( pow ( $ n - 1 , $ k ) + $ p * ( $ n - 1 ) ) \\/ $ n ; } $ n = 4 ; $ k = 2 ; echo numOfways ( $ n , $ k ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Find the smallest number whose sum of digits is N | Java program to find the smallest number whose sum of digits is also N ; Function to get sum of digits ; Function to find the smallest number whose sum of digits is also N ; Checking if number has sum of digits = N ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"class GFG { static int getSum ( int n ) { int sum = 0 ; while ( n != 0 ) { sum = sum + n % 10 ; n = n \\/ 10 ; } return sum ; } static void smallestNumber ( int N ) { int i = 1 ; while ( 1 != 0 ) { if ( getSum ( i ) == N ) { System . out . print ( i ) ; break ; } i ++ ; } } public static void main ( String [ ] args ) { int N = 10 ; smallestNumber ( N ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Make all numbers of an array equal | C # implementation of above approach ; Function that returns true if all the array elements can be made equal with the given operation ; Divide number by 2 ; Divide number by 3 ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static bool EqualNumbers ( int [ ] a , int n ) { for ( int i = 0 ; i < n ; i ++ ) { while ( a [ i ] % 2 == 0 ) { a [ i ] \\/= 2 ; } while ( a [ i ] % 3 == 0 ) { a [ i ] \\/= 3 ; } if ( a [ i ] != a [ 0 ] ) { return false ; } } return true ; } public static void Main ( ) { int [ ] a = { 50 , 75 , 150 } ; int n = a . Length ; if ( EqualNumbers ( a , n ) ) { Console . WriteLine ( \\\" Yes \\\" ) ; } else { Console . WriteLine ( \\\" No \\\" ) ; } } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Queries on count of points lie inside a circle | JAVA Code for Queries on count of points lie inside a circle ; Computing the x ^ 2 + y ^ 2 for each given points and sorting them . ; Return count of points lie inside or on circumference of circle using binary search on p [ 0. . n - 1 ] ; Driver program to test above function ; Compute distances of all points and keep the distances sorted so that query can work in O ( logn ) using Binary Search . ; Print number of points in a circle of radius 3. ; Print number of points in a circle of radius 32.\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { public static void preprocess ( int p [ ] , int x [ ] , int y [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) p [ i ] = x [ i ] * x [ i ] + y [ i ] * y [ i ] ; Arrays . sort ( p ) ; } public static int query ( int p [ ] , int n , int rad ) { int start = 0 , end = n - 1 ; while ( ( end - start ) > 1 ) { int mid = ( start + end ) \\/ 2 ; double tp = Math . sqrt ( p [ mid ] ) ; if ( tp > ( rad * 1.0 ) ) end = mid - 1 ; else start = mid ; } double tp1 = Math . sqrt ( p [ start ] ) ; double tp2 = Math . sqrt ( p [ end ] ) ; if ( tp1 > ( rad * 1.0 ) ) return 0 ; else if ( tp2 <= ( rad * 1.0 ) ) return end + 1 ; else return start + 1 ; } public static void main ( String [ ] args ) { int x [ ] = { 1 , 2 , 3 , - 1 , 4 } ; int y [ ] = { 1 , 2 , 3 , - 1 , 4 } ; int n = x . length ; int p [ ] = new int [ n ] ; preprocess ( p , x , y , n ) ; System . out . println ( query ( p , n , 3 ) ) ; System . out . println ( query ( p , n , 32 ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Maximum number of partitions that can be sorted individually to make sorted | java program to find Maximum number of partitions such that we can get a sorted array ; Function to find maximum partitions . ; Find maximum in prefix arr [ 0. . i ] ; If maximum so far is equal to index , we can make a new partition ending at index i . ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"import java . io . * ; class GFG { static int maxPartitions ( int arr [ ] , int n ) { int ans = 0 , max_so_far = 0 ; for ( int i = 0 ; i < n ; ++ i ) { max_so_far = Math . max ( max_so_far , arr [ i ] ) ; if ( max_so_far == i ) ans ++ ; } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 0 , 2 , 3 , 4 } ; int n = arr . length ; System . out . println ( maxPartitions ( arr , n ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Ways to Remove Edges from a Complete Graph to make Odd Edges | C ++ implementation of the approach ; Function to return the number of ways to remove edges from the graph so that odd number of edges are left in the graph ; Total number of edges ; Driver code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int countWays ( int N ) { int E = ( N * ( N - 1 ) ) \\/ 2 ; if ( N == 1 ) return 0 ; return pow ( 2 , E - 1 ) ; } int main ( ) { int N = 4 ; cout << countWays ( N ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Program to count leaf nodes in a binary tree | Class containing left and right child of current node and key value ; Root of the Binary Tree ; Function to get the count of leaf nodes in a binary tree ; Driver program to test above functions ; create a tree ; get leaf count of the abve tree\\\"\\nHow can the above be solved in Java?\",\"targets\":\"class Node { int data ; Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } public class BinaryTree { Node root ; int getLeafCount ( ) { return getLeafCount ( root ) ; } int getLeafCount ( Node node ) { if ( node == null ) return 0 ; if ( node . left == null && node . right == null ) return 1 ; else return getLeafCount ( node . left ) + getLeafCount ( node . right ) ; } public static void main ( String args [ ] ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 5 ) ; System . out . println ( \\\" The ▁ leaf ▁ count ▁ of ▁ binary ▁ tree ▁ is ▁ : ▁ \\\" + tree . getLeafCount ( ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"Find all factors of a natural number | Set 1 | C implementation of Naive method to print all divisors ; function to print the divisors ; Driver program to test above function\\nHow can the above be solved in C?\",\"targets\":\"#include \\nvoid printDivisors ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) if ( n % i == 0 ) printf ( \\\" % d ▁ \\\" , i ) ; } int main ( ) { printf ( \\\" The ▁ divisors ▁ of ▁ 100 ▁ are : ▁ \\n \\\" ) ; printDivisors ( 100 ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Maximum number of pair reductions possible on a given triplet | C # program for the above approach ; Function to count the maximum number of pair reductions possible on a given triplet ; Convert them into an array ; Stores count of operations ; Sort the array ; If the first two array elements reduce to 0 ; Apply the operations ; Increment count ; Print the maximum count ; Driver Code ; Given triplet\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static void maxOps ( int a , int b , int c ) { int [ ] arr = { a , b , c } ; int count = 0 ; while ( 1 != 0 ) { Array . Sort ( arr ) ; if ( arr [ 0 ] == 0 && arr [ 1 ] == 0 ) break ; arr [ 1 ] -= 1 ; arr [ 2 ] -= 1 ; count += 1 ; } Console . WriteLine ( count ) ; } public static void Main ( String [ ] args ) { int a = 4 , b = 3 , c = 2 ; maxOps ( a , b , c ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Minimum and Maximum values of an expression with * and + | Utility method to check whether a character is operator or not ; method prints minimum and maximum value obtainable from an expression ; store operator and numbers in different vectors ; storing last number in vector ; initializing minval and maxval 2D array ; initializing main diagonal by num values ; looping similar to matrix chain multiplication and updating both 2D arrays ; if current operator is ' + ' , updating tmp variable by addition ; if current operator is ' * ' , updating tmp variable by multiplication ; updating array values by tmp variables ; last element of first row will store the result ; Driver code to test above methods\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function isOperator ( op ) { return ( op == ' ' op == ' ' ) ; } function printMinAndMaxValueOfExp ( exp ) { let num = [ ] ; let opr = [ ] ; let tmp = \\\" \\\" ; for ( let i = 0 ; i < exp . length ; i ++ ) { if ( isOperator ( exp [ i ] ) ) { opr . push ( exp [ i ] ) ; num . push ( parseInt ( tmp ) ) ; tmp = \\\" \\\" ; } else { tmp += exp [ i ] ; } } num . push ( parseInt ( tmp ) ) ; let len = num . length ; let minVal = new Array ( len ) ; let maxVal = new Array ( len ) ; for ( let i = 0 ; i < len ; i ++ ) { minVal [ i ] = new Array ( len ) ; maxVal [ i ] = new Array ( len ) ; for ( let j = 0 ; j < len ; j ++ ) { minVal [ i ] [ j ] = Number . MAX_VALUE ; maxVal [ i ] [ j ] = 0 ; if ( i == j ) minVal [ i ] [ j ] = maxVal [ i ] [ j ] = num [ i ] ; } } for ( let L = 2 ; L <= len ; L ++ ) { for ( let i = 0 ; i < len - L + 1 ; i ++ ) { let j = i + L - 1 ; for ( let k = i ; k < j ; k ++ ) { let minTmp = 0 , maxTmp = 0 ; if ( opr [ k ] == ' ' ) { minTmp = minVal [ i ] [ k ] + minVal [ k + 1 ] [ j ] ; maxTmp = maxVal [ i ] [ k ] + maxVal [ k + 1 ] [ j ] ; } else if ( opr [ k ] == ' ' ) { minTmp = minVal [ i ] [ k ] * minVal [ k + 1 ] [ j ] ; maxTmp = maxVal [ i ] [ k ] * maxVal [ k + 1 ] [ j ] ; } if ( minTmp < minVal [ i ] [ j ] ) minVal [ i ] [ j ] = minTmp ; if ( maxTmp > maxVal [ i ] [ j ] ) maxVal [ i ] [ j ] = maxTmp ; } } } document . write ( \\\" \\\" + minVal [ 0 ] [ len - 1 ] + \\\" \\\" + maxVal [ 0 ] [ len - 1 ] ) ; } let expression = \\\" \\\" ; printMinAndMaxValueOfExp ( expression ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Intersecting rectangle when bottom | CPP program to find intersection rectangle of given two rectangles . ; function to find intersection rectangle of given two rectangles . ; gives bottom - left point of intersection rectangle ; gives top - right point of intersection rectangle ; no intersection ; gives top - left point of intersection rectangle ; gives bottom - right point of intersection rectangle ; Driver code ; bottom - left and top - right corners of first rectangle ; bottom - left and top - right corners of first rectangle ; function call\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; void FindPoints ( int x1 , int y1 , int x2 , int y2 , int x3 , int y3 , int x4 , int y4 ) { int x5 = max ( x1 , x3 ) ; int y5 = max ( y1 , y3 ) ; int x6 = min ( x2 , x4 ) ; int y6 = min ( y2 , y4 ) ; if ( x5 > x6 y5 > y6 ) { cout << \\\" No ▁ intersection \\\" ; return ; } cout << \\\" ( \\\" << x5 << \\\" , ▁ \\\" << y5 << \\\" ) ▁ \\\" ; cout << \\\" ( \\\" << x6 << \\\" , ▁ \\\" << y6 << \\\" ) ▁ \\\" ; int x7 = x5 ; int y7 = y6 ; cout << \\\" ( \\\" << x7 << \\\" , ▁ \\\" << y7 << \\\" ) ▁ \\\" ; int x8 = x6 ; int y8 = y5 ; cout << \\\" ( \\\" << x8 << \\\" , ▁ \\\" << y8 << \\\" ) ▁ \\\" ; } int main ( ) { int x1 = 0 , y1 = 0 , x2 = 10 , y2 = 8 ; int x3 = 2 , y3 = 3 , x4 = 7 , y4 = 9 ; FindPoints ( x1 , y1 , x2 , y2 , x3 , y3 , x4 , y4 ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Count words in a given string | C # program to count total number of words in the string ; Function to count total number of words in the string ; Check if the string is null or empty then return zero ; Converting the given string into a character array ; Check if the character is a letter and index of character array doesn 't equal to end of line that means, it is a word and set isWord by true ; Check if the character is not a letter that means there is a space , then we increment the wordCount by one and set the isWord by false ; Check for the last word of the sentence and increment the wordCount by one ; Return the total number of words in the string ; Driver Code ; Given String str ; Print the result\\\"\\nSolution in C#:\",\"targets\":\"using System ; public class GFG { static int countWords ( String str ) { if ( str == null ) { return 0 ; } int wordCount = 0 ; bool isWord = false ; int endOfLine = str . Length - 1 ; char [ ] ch = str . ToCharArray ( ) ; for ( int i = 0 ; i < ch . Length ; i ++ ) { if ( Char . IsLetter ( ch [ i ] ) && i != endOfLine ) { isWord = true ; } else if ( ! Char . IsLetter ( ch [ i ] ) && isWord ) { wordCount ++ ; isWord = false ; } else if ( Char . IsLetter ( ch [ i ] ) && i == endOfLine ) { wordCount ++ ; } } return wordCount ; } static public void Main ( ) { string str = \\\" One ▁ two \\t three \\n ▁ four \\t five ▁ \\\" ; Console . WriteLine ( \\\" No ▁ of ▁ words ▁ : ▁ \\\" + countWords ( str ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Longest set of Palindrome Numbers from the range [ L , R ] with at most K difference between its maximum and minimum | Java program for the above approach ; Function to find the maximum size of group of palindrome numbers having difference between maximum and minimum element at most K ; Stores the all the palindromic numbers in the range [ L , R ] ; Traverse over the range [ L , R ] ; If i is a palindrome ; Append the number in the list ; Stores count of maximum palindromic numbers ; Iterate each element in the list ; Calculate rightmost index in the list < current element + K ; Check if there is rightmost index from the current index ; Return the count ; Function to search the rightmost index of given number ; Store the rightmost index ; Calculate the mid ; If given number <= num ; Assign ans = mid ; Update low ; Update high ; return ans ; Function to check if the given number is palindrome or not ; Generate reverse of the given number ; If n is a palindrome ; Driver Code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; public class Main { static int countNumbers ( int L , int R , int K ) { ArrayList < Integer > list = new ArrayList < > ( ) ; for ( int i = L ; i <= R ; i ++ ) { if ( isPalindrome ( i ) ) { list . add ( i ) ; } } int count = 0 ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { int right_index = search ( list , list . get ( i ) + K - 1 ) ; if ( right_index != - 1 ) count = Math . max ( count , right_index - i + 1 ) ; } return count ; } static int search ( ArrayList < Integer > list , int num ) { int low = 0 , high = list . size ( ) - 1 ; int ans = - 1 ; while ( low <= high ) { int mid = low + ( high - low ) \\/ 2 ; if ( list . get ( mid ) <= num ) { ans = mid ; low = mid + 1 ; } else high = mid - 1 ; } return ans ; } static boolean isPalindrome ( int n ) { int rev = 0 ; int temp = n ; while ( n > 0 ) { rev = rev * 10 + n % 10 ; n \\/= 10 ; } return rev == temp ; } public static void main ( String args [ ] ) { int L = 98 , R = 112 ; int K = 13 ; System . out . print ( countNumbers ( L , R , K ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Minimum length of square to contain at least half of the given Coordinates | Function to Calculate Absolute Value ; Function to Calculate the Minimum value of M ; To store the minimum M for each point in array ; Sort the array ; Index at which atleast required point are inside square of length 2 * M ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function mod ( $ x ) { if ( $ x >= 0 ) return $ x ; return - $ x ; } function findSquare ( $ n ) { $ points = array ( array ( 1 , 2 ) , array ( -3 , 4 ) , array ( 1 , 78 ) , array ( -3 , -7 ) ) ; $ a [ $ n ] = array ( ) ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { $ x ; $ y ; $ x = $ points [ $ i ] [ 0 ] ; $ y = $ points [ $ i ] [ 1 ] ; $ a [ $ i ] = max ( mod ( $ x ) , mod ( $ y ) ) ; } sort ( $ a ) ; $ index = floor ( $ n \\/ 2 ) - 1 ; echo \\\" Minimum ▁ M ▁ required ▁ is : ▁ \\\" , $ a [ $ index ] , \\\" \\n \\\" ; } $ N = 4 ; findSquare ( $ N ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Program to print modified Binary triangle pattern | C # implementation to print the modified binary triangle pattern ; Function to print the modified binary pattern ; Loop to traverse the rows ; Loop to traverse the numbers in each row ; Check if j is 1 or i In either case print 1 ; Else print 0 ; Change the cursor to next line after each row ; Driver Code ; Function call\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static void modifiedBinaryPattern ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= i ; j ++ ) { if ( j == 1 j == i ) Console . Write ( 1 ) ; else Console . Write ( 0 ) ; } Console . WriteLine ( ) ; } } public static void Main ( ) { int n = 7 ; modifiedBinaryPattern ( n ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Count removal of pairs required to be empty all Balanced Parenthesis subsequences | Function to find the maximum count of pairs required to be removed such that subsequence of string does not contain any valid parenthesis ; Stores count of pairs of balanced parenthesis ; Stores count of curly balanced parenthesis ; Stores count of small balanced parenthesis ; Stores count of square balanced parenthesis ; Iterate over characters of the string ; Update cntCurly ; Update cntSml ; Update cntSqr ; Update cntCurly ; Update cntPairs ; Update cntSml ; Update cntPairs ; Update cntSml ; Update cntPairs ; Driver Code ; Given String ; Function call\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def cntBalancedParenthesis ( s , N ) :\\n\\tcntPairs = 0 ;\\n\\tcntCurly = 0 ;\\n\\tcntSml = 0 ;\\n\\tcntSqr = 0 ;\\n\\tfor i in range ( N ) :\\n\\t\\tif ( ord ( s [ i ] ) == ord ( ' { ' ) ) :\\n\\t\\t\\tcntCurly += 1 ;\\n\\t\\telif ( ord ( s [ i ] ) == ord ( ' ( ' ) ) :\\n\\t\\t\\tcntSml += 1 ;\\n\\t\\telif ( ord ( s [ i ] ) == ord ( ' [ ' ) ) :\\n\\t\\t\\tcntSqr += 1 ;\\n\\t\\telif ( ord ( s [ i ] ) == ord ( ' } ' ) and cntCurly > 0 ) :\\n\\t\\t\\tcntCurly -= 1 ;\\n\\t\\t\\tcntPairs += 1 ;\\n\\t\\telif ( ord ( s [ i ] ) == ord ( ' ) ' ) and cntSml > 0 ) :\\n\\t\\t\\tcntSml -= 1 ;\\n\\t\\t\\tcntPairs += 1 ;\\n\\t\\telif ( ord ( s [ i ] ) == ord ( ' ] ' ) and cntSqr > 0 ) :\\n\\t\\t\\tcntSqr -= 1 ;\\n\\t\\t\\tcntPairs += 1 ;\\n\\tprint ( cntPairs ) ;\\nif __name__ == ' _ _ main _ _ ' :\\n\\ts = \\\" { ( } ) \\\" ;\\n\\tN = len ( s ) ;\\n\\tcntBalancedParenthesis ( s , N ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Average of a stream of numbers | Returns the new average after including x ; Prints average of a stream of numbers ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"def getAvg ( x , n , sum ) :\\n\\tsum = sum + x ;\\n\\treturn float ( sum ) \\/ n ;\\ndef streamAvg ( arr , n ) :\\n\\tavg = 0 ;\\n\\tsum = 0 ;\\n\\tfor i in range ( n ) :\\n\\t\\tavg = getAvg ( arr [ i ] , i + 1 , sum ) ;\\n\\t\\tsum = avg * ( i + 1 ) ;\\n\\t\\tprint ( \\\" Average ▁ of ▁ \\\" , end = \\\" \\\" ) ;\\n\\t\\tprint ( i + 1 , end = \\\" \\\" ) ;\\n\\t\\tprint ( \\\" ▁ numbers ▁ is ▁ \\\" , end = \\\" \\\" ) ;\\n\\t\\tprint ( avg ) ;\\n\\treturn ;\\narr = [ 10 , 20 , 30 , 40 , 50 , 60 ] ;\\nn = len ( arr ) ;\\nstreamAvg ( arr , n ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Maximize Bitwise AND of first element with complement of remaining elements for any permutation of given Array | Function to maximize the value for the given function and the array elements ; Vector array to maintain which bit is set for which integer in the given array by saving index of that integer ; Check if j - th bit is set for i - th integer ; Push the index of that integer in setBit [ j ] ; Find the element having highest significant set bit unset in other elements ; Place that integer at 0 - th index ; Store the maximum AND value ; Return the answer ; Driver Code ; Function call\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def functionMax ( arr , n ) :\\n\\tsetBit = [ [ ] for i in range ( 32 ) ]\\n\\tfor i in range ( n ) :\\n\\t\\tfor j in range ( 32 ) :\\n\\t\\t\\tif ( arr [ i ] & ( 1 << j ) ) :\\n\\t\\t\\t\\tsetBit [ j ] . append ( i )\\n\\ti = 31\\n\\twhile ( i >= 0 ) :\\n\\t\\tif ( len ( setBit [ i ] ) == 1 ) :\\n\\t\\t\\ttemp = arr [ 0 ]\\n\\t\\t\\tarr [ 0 ] = arr [ setBit [ i ] [ 0 ] ]\\n\\t\\t\\tarr [ setBit [ i ] [ 0 ] ] = temp\\n\\t\\t\\tbreak\\n\\t\\ti -= 1\\n\\tmaxAnd = arr [ 0 ]\\n\\tfor i in range ( 1 , n , 1 ) :\\n\\t\\tmaxAnd = ( maxAnd & ( ~ arr [ i ] ) )\\n\\treturn maxAnd\\nif __name__ == ' _ _ main _ _ ' :\\n\\tarr = [ 1 , 2 , 4 , 8 , 16 ]\\n\\tn = len ( arr )\\n\\tprint ( functionMax ( arr , n ) )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Sort all even numbers in ascending order and then sort all odd numbers in descending order | To do two way sort . First sort even numbers in ascending order , then odd numbers in descending order . ; Make all odd numbers negative ; if ( arr [ i ] & 1 ) Check for odd ; Sort all numbers ; Retaining original array ; Driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function twoWaySort ( arr , n ) { for ( let i = 0 ; i < n ; i ++ ) arr [ i ] *= - 1 ; arr . sort ( ( a , b ) => a - b ) ; for ( let i = 0 ; i < n ; i ++ ) if ( arr [ i ] & 1 ) arr [ i ] *= - 1 ; } let arr = [ 1 , 3 , 2 , 7 , 5 , 4 ] ; let n = arr . length ; twoWaySort ( arr , n ) ; for ( let i = 0 ; i < n ; i ++ ) document . write ( arr [ i ] + \\\" \\\" ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Sudo Placement [ 1.7 ] | Greatest Digital Root | Java program to print the digital roots of a number ; Function to return dig - sum ; Function to print the Digital Roots ; store the largest digital roots ; Iterate till sqrt ( n ) ; if i is a factor ; get the digit sum of both factors i and n \\/ i ; if digit sum is greater then previous maximum ; if digit sum is greater then previous maximum ; if digit sum is same as then previous maximum , then check for larger divisor ; if digit sum is same as then previous maximum , then check for larger divisor ; Print the digital roots ; Driver Code ; Function call to print digital roots\\\"\\nHow can the above be solved in Java?\",\"targets\":\"class GFG { static int summ ( int n ) { if ( n == 0 ) return 0 ; return ( n % 9 == 0 ) ? 9 : ( n % 9 ) ; } static void printDigitalRoot ( int n ) { int maxi = 1 ; int dig = 1 ; for ( int i = 1 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { int d1 = summ ( n \\/ i ) ; int d2 = summ ( i ) ; if ( d1 > maxi ) { dig = n \\/ i ; maxi = d1 ; } if ( d2 > maxi ) { dig = i ; maxi = d2 ; } if ( d1 == maxi ) { if ( dig < ( n \\/ i ) ) { dig = n \\/ i ; maxi = d1 ; } } if ( d2 == maxi ) { if ( dig < i ) { dig = i ; maxi = d2 ; } } } } System . out . println ( dig + \\\" ▁ \\\" + maxi ) ; } public static void main ( String [ ] args ) { int n = 10 ; printDigitalRoot ( n ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Create matrix whose sum of diagonals in each sub matrix is even | C ++ program for the above approach ; Function to print N * N order matrix with all sub - matrix of even order is sum of its diagonal also even ; Even index ; Odd index ; Iterate two nested loop ; For even index the element should be consecutive odd ; for odd index the element should be consecutive even ; Driver Code ; Given order of matrix ; Function call\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; void evenSubMatrix ( int N ) { int even = 1 ; int odd = 2 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( ( i + j ) % 2 == 0 ) { cout << even << \\\" ▁ \\\" ; even += 2 ; } else { cout << odd << \\\" ▁ \\\" ; odd += 2 ; } } cout << \\\" \\n \\\" ; } } int main ( ) { int N = 4 ; evenSubMatrix ( N ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"The Lazy Caterer 's Problem | This function receives an integer n and returns the maximum number of pieces that can be made form pancake using n cuts ; Use the formula ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"def findPieces ( n ) :\\n\\treturn ( n * ( n + 1 ) ) \\/\\/ 2 + 1\\nprint ( findPieces ( 1 ) )\\nprint ( findPieces ( 2 ) )\\nprint ( findPieces ( 3 ) )\\nprint ( findPieces ( 50 ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"Selection Sort | C program for implementation of selection sort ; swap function ; sort function ; One by one move boundary of unsorted subarray ; Find the minimum element in unsorted array ; Swap the found minimum element with the first element ; Function to print an array ; Driver program to test above functions\\nHow can the above be solved in C?\",\"targets\":\"#include \\nvoid swap ( int * xp , int * yp ) { int temp = * xp ; * xp = * yp ; * yp = temp ; } void selectionSort ( int arr [ ] , int n ) { int i , j , min_idx ; for ( i = 0 ; i < n - 1 ; i ++ ) { min_idx = i ; for ( j = i + 1 ; j < n ; j ++ ) if ( arr [ j ] < arr [ min_idx ] ) min_idx = j ; swap ( & arr [ min_idx ] , & arr [ i ] ) ; } } void printArray ( int arr [ ] , int size ) { int i ; for ( i = 0 ; i < size ; i ++ ) printf ( \\\" % d ▁ \\\" , arr [ i ] ) ; printf ( \\\" \\n \\\" ) ; } int main ( ) { int arr [ ] = { 64 , 25 , 12 , 22 , 11 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; selectionSort ( arr , n ) ; printf ( \\\" Sorted ▁ array : ▁ \\n \\\" ) ; printArray ( arr , n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"An efficient way to check whether n | A simple PHP program to check if n - th Fibonacci number is multiple of 10. ; Returns true if n - th Fibonacci number is multiple of 10. ; Driver code\\\"\\nSolution in php:\",\"targets\":\"< ? php function fibonacci ( $ n ) { $ a = 0 ; $ b = 1 ; $ c ; if ( $ n <= 1 ) return $ n ; for ( $ i = 2 ; $ i <= $ n ; $ i ++ ) { $ c = $ a + $ b ; $ a = $ b ; $ b = $ c ; } return $ c ; } function isMultipleOf10 ( $ n ) { $ f = fibonacci ( 30 ) ; return ( $ f % 10 == 0 ) ; } $ n = 30 ; if ( isMultipleOf10 ( $ n ) ) echo \\\" Yes \\n \\\" ; else echo \\\" No \\n \\\" ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Pascal 's Triangle | Java program for Pascal ' s ▁ Triangle ▁ A ▁ O ( n ^ 2 ) ▁ time ▁ and ▁ O ( 1 ) ▁ extra ▁ space ▁ method ▁ for ▁ Pascal ' s Triangle ; used to represent C ( line , i ) ; The first value in a line is always 1 ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"import java . io . * ; class GFG { public static void printPascal ( int n ) { for ( int line = 1 ; line <= n ; line ++ ) { int C = 1 ; for ( int i = 1 ; i <= line ; i ++ ) { System . out . print ( C + \\\" ▁ \\\" ) ; C = C * ( line - i ) \\/ i ; } System . out . println ( ) ; } } public static void main ( String [ ] args ) { int n = 5 ; printPascal ( n ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Subtract 1 without arithmetic operators | PHP code to subtract one from a given number ; Flip all the set bits until we find a 1 ; flip the rightmost 1 bit ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function subtractOne ( $ x ) { $ m = 1 ; while ( ! ( $ x & $ m ) ) { $ x = $ x ^ $ m ; $ m <<= 1 ; } $ x = $ x ^ $ m ; return $ x ; } echo subtractOne ( 13 ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Check if two arrays are permutations of each other using Mathematical Operation | Java code to check if arrays are permutations of eah other ; Function to check if arrays are permutations of each other . ; Calculating sum and multiply of first array ; Calculating sum and multiply of second array ; If sum and mul of both arrays are equal , return true , else return false . ; Driver code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . io . * ; class GFG { static boolean arePermutations ( int a [ ] , int b [ ] , int n , int m ) { int sum1 = 0 , sum2 = 0 , mul1 = 1 , mul2 = 1 ; for ( int i = 0 ; i < n ; i ++ ) { sum1 += a [ i ] ; mul1 *= a [ i ] ; } for ( int i = 0 ; i < m ; i ++ ) { sum2 += b [ i ] ; mul2 *= b [ i ] ; } return ( ( sum1 == sum2 ) && ( mul1 == mul2 ) ) ; } public static void main ( String [ ] args ) { int a [ ] = { 1 , 3 , 2 } ; int b [ ] = { 3 , 1 , 2 } ; int n = a . length ; int m = b . length ; if ( arePermutations ( a , b , n , m ) == true ) System . out . println ( \\\" Yes \\\" ) ; else System . out . println ( \\\" No \\\" ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Modify string by removing vowels in between two consonants | C # program to remove all Vowels in between two consonants from the string ; Function to check if the character x is a vowel or not ; Returns the updated string formed after removing all the Sandwiched Vowels from the given string ; string to store the Updated String after removing the Sandwiched Vowels ; traverse the string from left to right ; if the current character is the first or the last character of the string then , this needs to be appended to the updatedString , since the corner alphabet irrespective of it being a vowel or a consonant , is never ' Sandwiched ' ; Check if the current character of the string is a vowel and both the previous and the next characters are consonants , if so then this is a sandwiched vowel , thus is ignored and not appended to the updated string ; if this character is not a sandwiched Vowel append it to the updated String ; Driver Code ; Remove all the Sandwitched Vowels\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static bool isVowel ( char x ) { if ( x == ' a ' x == ' e ' x == ' i ' x == ' o ' x == ' u ' ) return true ; else return false ; } static String updateSandwichedVowels ( String a ) { int n = a . Length ; String updatedString = \\\" \\\" ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == 0 i == n - 1 ) { updatedString += a [ i ] ; continue ; } if ( ( isVowel ( a [ i ] ) ) == true && isVowel ( a [ i - 1 ] ) == false && isVowel ( a [ i + 1 ] ) == false ) { continue ; } updatedString += a [ i ] ; } return updatedString ; } public static void Main ( ) { String str = \\\" geeksforgeeks \\\" ; String updatedString = updateSandwichedVowels ( str ) ; Console . WriteLine ( updatedString ) ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Check if row | C # implementation to check if row - major order traversal of matrix is palindrome or not ; Function to check if row - major order traversal of the matrix is is palindrome ; Loop to check if the matrix is matrix is palindrome or not ; Driver Code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static bool isPal ( int [ , ] a , int n , int m ) { for ( int i = 0 ; i < n \\/ 2 ; i ++ ) { for ( int j = 0 ; j < m - 1 ; j ++ ) { if ( a [ i , j ] != a [ n - 1 - i , m - 1 - j ] ) return false ; } } return true ; } public static void Main ( String [ ] args ) { int n = 3 , m = 3 ; int [ , ] a = { { 1 , 2 , 3 } , { 4 , 5 , 4 } , { 3 , 2 , 1 } } ; if ( isPal ( a , n , m ) ) { Console . Write ( \\\" YES \\\" + \\\" \\n \\\" ) ; } else { Console . Write ( \\\" NO \\\" + \\\" \\n \\\" ) ; } } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Pairs of complete strings in two sets of strings | Returns count of complete pairs from set [ 0. . n - 1 ] and set2 [ 0. . m - 1 ] ; Consider all pairs of both strings ; Create a concatenation of current pair ; Compute frequencies of all characters in the concatenated String . ; If frequency of any character is not greater than 0 , then this pair is not complete . ; Driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function countCompletePairs ( set1 , set2 , n , m ) { let result = 0 ; for ( let i = 0 ; i < n ; i ++ ) { for ( let j = 0 ; j < m ; j ++ ) { let concat = set1 [ i ] + set2 [ j ] ; let frequency = new Array ( 26 ) ; for ( let i = 0 ; i < 26 ; i ++ ) { frequency [ i ] = 0 ; } for ( let k = 0 ; k < concat . length ; k ++ ) { frequency [ concat [ k ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; } let k ; for ( k = 0 ; k < 26 ; k ++ ) { if ( frequency [ k ] < 1 ) { break ; } } if ( k == 26 ) { result ++ ; } } } return result ; } let set1 = [ \\\" \\\" , \\\" \\\" , \\\" \\\" , \\\" \\\" ] ; let set2 = [ \\\" \\\" , \\\" \\\" , \\\" \\\" ] let n = set1 . length ; let m = set2 . length ; document . write ( countCompletePairs ( set1 , set2 , n , m ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Sort the array in a given index range | Java program to sort the array in a given index range ; Function to sort the elements of the array from index a to index b ; Variables to store start and end of the index range ; Sort the subarray from arr [ l ] to arr [ r ] ; Print the modified array ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"import java . io . * ; import java . util . * ; import java . lang . * ; class GFG { static void partSort ( int [ ] arr , int N , int a , int b ) { int l = Math . min ( a , b ) ; int r = Math . max ( a , b ) ; Arrays . sort ( arr , l , r + 1 ) ; for ( int i = 0 ; i < N ; i ++ ) System . out . print ( arr [ i ] + \\\" ▁ \\\" ) ; } public static void main ( String args [ ] ) { int [ ] arr = { 7 , 8 , 4 , 5 , 2 } ; int a = 1 , b = 4 ; int N = arr . length ; partSort ( arr , N , a , b ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"Check if a number is multiple of 5 without using \\/ and % operators | C program for the above approach ; assumes that n is a positive integer ; Driver Code\\nHow can the above be solved in C?\",\"targets\":\"#include \\nbool isMultipleof5 ( int n ) { while ( n > 0 ) n = n - 5 ; if ( n == 0 ) return true ; return false ; } int main ( ) { int n = 19 ; if ( isMultipleof5 ( n ) == true ) printf ( \\\" % d ▁ is ▁ multiple ▁ of ▁ 5 \\n \\\" , n ) ; else printf ( \\\" % d ▁ is ▁ not ▁ a ▁ multiple ▁ of ▁ 5 \\n \\\" , n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Remove minimum elements from ends of array so that sum decreases by at least K | O ( N ) | C ++ implementation of the approach ; Function to return the count of minimum elements to be removed from the ends of the array such that the sum of the array decrease by at least K ; To store the final answer ; Maximum possible sum required ; Left point ; Right pointer ; Total current sum ; Two pointer loop ; If the sum fits ; Update the answer ; Update the total sum ; Increment the left pointer ; Driver code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int minCount ( int * arr , int n , int k ) { int ans = 0 ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; sum -= k ; int l = 0 ; int r = 0 ; int tot = 0 ; while ( l < n ) { if ( tot <= sum ) { ans = max ( ans , r - l ) ; if ( r == n ) break ; tot += arr [ r ++ ] ; } else { tot -= arr [ l ++ ] ; } } return ( n - ans ) ; } int main ( ) { int arr [ ] = { 1 , 11 , 5 , 5 } ; int n = sizeof ( arr ) \\/ sizeof ( int ) ; int k = 11 ; cout << minCount ( arr , n , k ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Find count of Almost Prime numbers from 1 to N | PHP program to count almost prime numbers from 1 to n ; Create a boolean array \\\" prime [ 0 . . n ] \\\" and initialize all entries it as true . A value in prime [ i ] will finally be false if i is Not a prime , else true . ; If prime [ p ] is not changed , then it is a prime ; Update all multiples of p ; Function to count almost prime numbers from 1 to n ; to store required answer ; 6 is first almost prime number ; to count prime factors ; if it is perfect square ; if I is almost prime number ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php $ N = 100005 ; $ prime = array_fill ( 0 , $ N , true ) ; function SieveOfEratosthenes ( ) { global $ N , $ prime ; $ prime [ 1 ] = false ; for ( $ p = 2 ; $ p < ( int ) ( sqrt ( $ N ) ) ; $ p ++ ) { if ( $ prime [ $ p ] == true ) for ( $ i = 2 * $ p ; $ i < $ N ; $ i += $ p ) $ prime [ $ i ] = false ; } } function almostPrimes ( $ n ) { global $ prime ; $ ans = 0 ; for ( $ i = 6 ; $ i < $ n + 1 ; $ i ++ ) { $ c = 0 ; for ( $ j = 2 ; $ i >= $ j * $ j ; $ j ++ ) { if ( $ i % $ j == 0 ) { if ( $ j * $ j == $ i ) { if ( $ prime [ $ j ] ) $ c += 1 ; } else { if ( $ prime [ $ j ] ) $ c += 1 ; if ( $ prime [ ( $ i \\/ $ j ) ] ) $ c += 1 ; } } } if ( $ c == 2 ) $ ans += 1 ; } return $ ans ; } SieveOfEratosthenes ( ) ; $ n = 21 ; print ( almostPrimes ( $ n ) ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Total character pairs from two strings , with equal number of set bits in their ascii value | C # implementation of the approach ; Function to return the count of valid pairs ; Store frequency of number of set bits for s1 ; Store frequency of number of set bits for s2 ; Calculate total pairs ; Return the count of valid pairs ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; using System . Linq ; class GFG { static int totalPairs ( string s1 , string s2 ) { int count = 0 ; int [ ] arr1 = new int [ 7 ] ; int [ ] arr2 = new int [ 7 ] ; for ( int i = 0 ; i < s1 . Length ; i ++ ) { int set_bits = Convert . ToString ( ( int ) s1 [ i ] , 2 ) . Count ( c => c == '1' ) ; arr1 [ set_bits ] ++ ; } for ( int i = 0 ; i < s2 . Length ; i ++ ) { int set_bits = Convert . ToString ( ( int ) s2 [ i ] , 2 ) . Count ( c => c == '1' ) ; arr2 [ set_bits ] ++ ; } for ( int i = 1 ; i <= 6 ; i ++ ) count += ( arr1 [ i ] * arr2 [ i ] ) ; return count ; } static void Main ( ) { string s1 = \\\" geeks \\\" ; string s2 = \\\" forgeeks \\\" ; Console . WriteLine ( totalPairs ( s1 , s2 ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Insert minimum number in array so that sum of array becomes prime | C # program to find minimum number to insert in array so their sum is prime ; function to check if a number is prime or not ; Corner case ; Check from 2 to n - 1 ; Find prime number greater than a number ; find prime greater than n ; check if num is prime ; increment num ; To find number to be added so sum of array is prime ; To find sum of array elements ; if sum is already prime return 0 ; To find prime number greater than sum ; Return difference of sum and num ; Driver Code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static bool isPrime ( int n ) { if ( n <= 1 ) return false ; for ( int i = 2 ; i < n ; i ++ ) if ( n % i == 0 ) return false ; return true ; } static int findPrime ( int n ) { int num = n + 1 ; while ( num > 0 ) { if ( isPrime ( num ) ) return num ; num = num + 1 ; } return 0 ; } static int minNumber ( int [ ] arr , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; if ( isPrime ( sum ) ) return 0 ; int num = findPrime ( sum ) ; return num - sum ; } public static void Main ( ) { int [ ] arr = { 2 , 4 , 6 , 8 , 12 } ; int n = arr . Length ; Console . Write ( minNumber ( arr , n ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Probability of rain on N + 1 th day | Function to find the probability ; count 1 ; find probability ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function rainDayProbability ( $ a , $ n ) { $ count = 0 ; $ m ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { if ( $ a [ $ i ] == 1 ) $ count ++ ; } $ m = $ count \\/ $ n ; return $ m ; } $ a = array ( 1 , 0 , 1 , 0 , 1 , 1 , 1 , 1 ) ; $ n = count ( $ a ) ; echo rainDayProbability ( $ a , $ n ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Largest right circular cylinder within a cube | Function to find the biggest right circular cylinder ; side cannot be negative ; radius of right circular cylinder ; height of right circular cylinder ; volume of right circular cylinder ; Driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function findVolume ( a ) { if ( a < 0 ) return - 1 ; var r = a \\/ 2 ; var h = a ; var V = ( 3.14 * Math . pow ( r , 2 ) * h ) ; return V ; } var a = 5 ; document . write ( findVolume ( a ) ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Binomial Coefficient | DP | Javascript program for space optimized Dynamic Programming Solution of Binomial Coefficient ; nC0 is 1 ; Compute next row of pascal triangle using the previous row ; Driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function binomialCoeff ( n , k ) { let C = new Array ( k + 1 ) ; C . fill ( 0 ) ; C [ 0 ] = 1 ; for ( let i = 1 ; i <= n ; i ++ ) { for ( let j = Math . min ( i , k ) ; j > 0 ; j -- ) C [ j ] = C [ j ] + C [ j - 1 ] ; } return C [ k ] ; } let n = 5 , k = 2 ; document . write ( \\\" \\\" + n + \\\" \\\" + k + \\\" \\\" + binomialCoeff ( n , k ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Toggling k | Java program to toogle k - th bit of a number ; main function\\\"\\nSolution in Java:\",\"targets\":\"class Toggle { static int toggleKthBit ( int n , int k ) { return ( n ^ ( 1 << ( k - 1 ) ) ) ; } public static void main ( String [ ] args ) { int n = 5 , k = 1 ; System . out . println ( toggleKthBit ( n , k ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Sum of series 1 * 1 ! + 2 * 2 ! + …… . . + n * n ! | PHP program to find sum of the series . ; Function to calculate required series ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function factorial ( $ n ) { $ res = 1 ; for ( $ i = 2 ; $ i <= $ n ; $ i ++ ) $ res = $ res * $ i ; return $ res ; } function calculateSeries ( $ n ) { return factorial ( $ n + 1 ) - 1 ; } $ n = 3 ; echo calculateSeries ( $ n ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Find sum of divisors of all the divisors of a natural number | C # program to find sum of divisors of all the divisors of a natural number . ; Returns sum of divisors of all the divisors of n ; Calculating powers of prime factors and storing them in a map mp [ ] . ; If n is a prime number ; For each prime factor , calculating ( p ^ ( a + 1 ) - 1 ) \\/ ( p - 1 ) and adding it to answer . ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; using System . Collections . Generic ; class GFG { public static int sumDivisorsOfDivisors ( int n ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int j = 2 ; j <= Math . Sqrt ( n ) ; j ++ ) { int count = 0 ; while ( n % j == 0 ) { n \\/= j ; count ++ ; } if ( count != 0 ) mp . Add ( j , count ) ; } if ( n != 1 ) mp . Add ( n , 1 ) ; int ans = 1 ; foreach ( KeyValuePair < int , int > entry in mp ) { int pw = 1 ; int sum = 0 ; for ( int i = entry . Value + 1 ; i >= 1 ; i -- ) { sum += ( i * pw ) ; pw = entry . Key ; } ans *= sum ; } return ans ; } public static void Main ( String [ ] args ) { int n = 10 ; Console . WriteLine ( sumDivisorsOfDivisors ( n ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Program for array rotation | Function to left Rotate arr [ ] of size n by 1 ; Function to left rotate arr of size n by d ; utility function to print an array ; Driver program to test above functions\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function leftRotatebyOne ( arr , n ) { var i , temp ; temp = arr [ 0 ] ; for ( i = 0 ; i < n - 1 ; i ++ ) arr [ i ] = arr [ i + 1 ] ; arr [ n - 1 ] = temp ; } function leftRotate ( arr , d , n ) { for ( i = 0 ; i < d ; i ++ ) leftRotatebyOne ( arr , n ) ; } function printArray ( arr , n ) { for ( i = 0 ; i < n ; i ++ ) document . write ( arr [ i ] + \\\" \\\" ) ; } var arr = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 ] ; leftRotate ( arr , 2 , 7 ) ; printArray ( arr , 7 ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Permutation present at the middle of lexicographic ordering of permutations of at most length N made up integers up to K | C # program for the above approach ; Function that finds the middle the lexicographical smallest sequence ; If K is even ; First element is K \\/ 2 ; Remaining elements of the sequence are all integer K ; Stores the sequence when K is odd ; Iterate over the range [ 0 , N \\/ 2 ] ; Check if the sequence ends with in 1 or not ; Remove the sequence ending in 1 ; If it doesn 't end in 1 ; Decrement by 1 ; Insert K to the sequence till its size is N ; Print the sequence stored in the vector ; Driver Code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; using System . Collections . Generic ; class GFG { static void lexiMiddleSmallest ( int K , int N ) { if ( K % 2 == 0 ) { Console . Write ( K \\/ 2 + \\\" ▁ \\\" ) ; for ( int i = 0 ; i < N - 1 ; ++ i ) { Console . Write ( K + \\\" ▁ \\\" ) ; } Console . WriteLine ( ) ; return ; } List < int > a = new List < int > ( ) ; for ( int i = 0 ; i < N \\/ 2 ; ++ i ) { if ( a [ a . Count - 1 ] == 1 ) { a . Remove ( a . Count - 1 ) ; } else { a [ a . Count - 1 ] -= 1 ; while ( ( int ) a . Count < N ) { a . Add ( K ) ; } } } foreach ( int i in a ) { Console . Write ( i + \\\" ▁ \\\" ) ; } Console . WriteLine ( ) ; } public static void Main ( ) { int K = 2 , N = 4 ; lexiMiddleSmallest ( K , N ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Pascal 's Triangle | C program for Pascals Triangle A O ( n ^ 2 ) time and O ( 1 ) extra space function for Pascal 's Triangle ; used to represent C ( line , i ) ; The first value in a line is always 1 ; Driver code\\\"\\nSolution in C:\",\"targets\":\"void printPascal ( int n ) { for ( int line = 1 ; line <= n ; line ++ ) { int C = 1 ; for ( int i = 1 ; i <= line ; i ++ ) { printf ( \\\" % d ▁ \\\" , C ) ; C = C * ( line - i ) \\/ i ; } printf ( \\\" \\n \\\" ) ; } } int main ( ) { int n = 5 ; printPascal ( n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Count numbers having GCD with N equal to the number itself | Function to count numbers whose GCD with N is the number itself ; Stores the count of factors of N ; Iterate over the range [ 1 , sqrt ( N ) ] ; If i is divisible by i ; Increment count ; Avoid counting the same factor twice ; Return the resultant count ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"def countNumbers ( N ) :\\n\\tcount = 0\\n\\tfor i in range ( 1 , N + 1 ) :\\n\\t\\tif i * i > N :\\n\\t\\t\\tbreak\\n\\t\\tif ( N % i == 0 ) :\\n\\t\\t\\tcount += 1\\n\\t\\t\\tif ( N \\/\\/ i != i ) :\\n\\t\\t\\t\\tcount += 1\\n\\treturn count\\nif __name__ == ' _ _ main _ _ ' :\\n\\tN = 10\\n\\tprint ( countNumbers ( N ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Maximum difference between a pair of adjacent elements by excluding every element once | C # Program to implement the above approach ; Function to calculate maximum difference between adjacent elements excluding every array element once ; Compute maximum adjacent difference for whole array ; Store the maximum between arr_max and curr_max ; Append the result into a vector ; Print the result ; Driver Code\\\"\\nSolution in C#:\",\"targets\":\"using System ; using System . Collections . Generic ; class GFG { static void maxAdjacent ( int [ ] arr , int N ) { List < int > res = new List < int > ( ) ; int arr_max = Int32 . MinValue ; for ( int i = 1 ; i < N ; i ++ ) { arr_max = Math . Max ( arr_max , Math . Abs ( arr [ i - 1 ] - arr [ i ] ) ) ; } for ( int i = 1 ; i < N - 1 ; i ++ ) { int curr_max = Math . Abs ( arr [ i - 1 ] - arr [ i + 1 ] ) ; int ans = Math . Max ( curr_max , arr_max ) ; res . Add ( ans ) ; } foreach ( int x in res ) Console . Write ( x + \\\" ▁ \\\" ) ; Console . WriteLine ( ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 3 , 4 , 7 , 8 } ; int N = arr . Length ; maxAdjacent ( arr , N ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Minimum divide by 2 operations required to make GCD odd for given Array | python program for the above approac ; Function to find the minimum number of operations to make the GCD of the array odd ; Stores the minimum operations required ; Stores the powers of two for the current array element ; Dividing by 2 ; Increment the count ; Update the minimum operation required ; Return the result required ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"INT_MAX = 2147483647\\ndef minimumOperations ( arr , N ) :\\n\\tmini = INT_MAX\\n\\tfor i in range ( 0 , N ) :\\n\\t\\tcount = 0\\n\\t\\twhile ( arr [ i ] % 2 == 0 ) :\\n\\t\\t\\tarr [ i ] = arr [ i ] \\/\\/ 2\\n\\t\\t\\tcount += 1\\n\\t\\tif ( mini > count ) :\\n\\t\\t\\tmini = count\\n\\treturn mini\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tarr = [ 4 , 6 ]\\n\\tN = len ( arr )\\n\\tprint ( minimumOperations ( arr , N ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Check if N can be obtained from 1 by repetitively multiplying by 10 or 20 | Function to check if N can be obtained or not ; Count and remove trailing zeroes ; Check if remaining N is a power of 2 ; To check the condition to prlong YES or NO ; Driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function Is_possible ( N ) { let C = 0 ; let D = 0 ; while ( N % 10 == 0 ) { N = N \\/ 10 ; C += 1 ; } if ( Math . pow ( 2 , ( Math . log ( N ) \\/ ( Math . log ( 2 ) ) ) ) == N ) { D = ( Math . log ( N ) \\/ ( Math . log ( 2 ) ) ) ; if ( C >= D ) document . write ( \\\" \\\" ) ; else document . write ( \\\" \\\" ) ; } else document . write ( \\\" \\\" ) ; } let N = 2000000000000 ; Is_possible ( N ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Program to find area of a Trapezoid | Java program to calculate area of a trapezoid ; Function for the area ; Driver Code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . io . * ; class GFG { static double Area ( int b1 , int b2 , int h ) { return ( ( b1 + b2 ) \\/ 2 ) * h ; } public static void main ( String [ ] args ) { int base1 = 8 , base2 = 10 , height = 6 ; double area = Area ( base1 , base2 , height ) ; System . out . println ( \\\" Area ▁ is : ▁ \\\" + area ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Probability that the sum of all numbers obtained on throwing a dice N times lies between two given integers | Javascript program for above approach ; Function to calculate the probability for the given sum to be equal to sum in N throws of dice ; Base cases ; Driver Code ; Calculate probability of all sums from a to b ; Print the answer\\\"\\nSolution in Javascript:\",\"targets\":\"var dp = Array ( 105 ) . fill ( ) . map ( ( ) => Array ( 605 ) . fill ( 0.0 ) ) ; function find ( N , sum ) { if ( N < 0 sum < 0 ) return 0 ; if ( dp [ N ] [ sum ] > 0 ) return dp [ N ] [ sum ] ; if ( sum > 6 * N sum < N ) return 0 ; if ( N == 1 ) { if ( sum >= 1 && sum <= 6 ) return ( 1.0 \\/ 6 ) ; else return 0 ; } for ( var i = 1 ; i <= 6 ; i ++ ) dp [ N ] [ sum ] = dp [ N ] [ sum ] + find ( N - 1 , sum - i ) \\/ 6 ; return dp [ N ] [ sum ] ; } var N = 4 , a = 13 , b = 17 ; var probability = 0.0 ; for ( sum = a ; sum <= b ; sum ++ ) probability = probability + find ( N , sum ) ; document . write ( probability . toFixed ( 6 ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Check if an array of 1 s and 2 s can be divided into 2 parts with equal sum | Java implementation of the above approach : ; Function to check if it is possible to split the array in two parts with equal sum ; Calculate sum of elements and count of 1 's ; If total sum is odd , return False ; If sum of each part is even , return True ; If sum of each part is even but there is atleast one 1 ; Driver Code\\\"\\nSolution in Java:\",\"targets\":\"class GFG { static boolean isSpiltPossible ( int n , int a [ ] ) { int sum = 0 , c1 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; if ( a [ i ] == 1 ) { c1 ++ ; } } if ( sum % 2 != 0 ) return false ; if ( ( sum \\/ 2 ) % 2 == 0 ) return true ; if ( c1 > 0 ) return true ; else return false ; } public static void main ( String [ ] args ) { int n = 3 ; int a [ ] = { 1 , 1 , 2 } ; if ( isSpiltPossible ( n , a ) ) System . out . println ( \\\" YES \\\" ) ; else System . out . println ( \\\" NO \\\" ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Generate two output strings depending upon occurrence of character in input string . | Java program to print two strings made of character occurring once and multiple times ; function to print two strings generated from single string one with characters occurring onces other with character occurring multiple of times ; initialize hashtable with zero entry ; perform hashing for input string ; generate string ( str1 ) consisting char occurring once and string ( str2 ) consisting char occurring multiple times ; print both strings ; driver program\\\"\\nSolution in Java:\",\"targets\":\"class GFG { final static int MAX_CHAR = 256 ; static void printDuo ( String str ) { int countChar [ ] = new int [ MAX_CHAR ] ; int n = str . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { countChar [ str . charAt ( i ) - ' a ' ] ++ ; } String str1 = \\\" \\\" , str2 = \\\" \\\" ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { if ( countChar [ i ] > 1 ) { str2 = str2 + ( char ) ( i + ' a ' ) ; } else if ( countChar [ i ] == 1 ) { str1 = str1 + ( char ) ( i + ' a ' ) ; } } System . out . print ( \\\" String ▁ with ▁ characters ▁ occurring ▁ \\\" + \\\"once:\\n\\\"); System . out . print ( str1 + \\\"\\n\\\"); System . out . print ( \\\" String ▁ with ▁ characters ▁ occurring ▁ \\\" + \\\"multiple times:\\n\\\"); System . out . print ( str2 + \\\"\\n\\\"); System . out . print ( \\\" \\\" ) ; } public static void main ( String [ ] args ) { String str = \\\" lovetocode \\\" ; printDuo ( str ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Hexanacci Numbers | Java simple recursive program to print Nth Hexanacci numbers . ; Function to print the Nth Hexanacci number ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"import java . util . * ; class GFG { static int printhexaRec ( int n ) { if ( n == 0 n == 1 n == 2 n == 3 n == 4 n == 5 ) return 0 ; else if ( n == 6 ) return 1 ; else return ( printhexaRec ( n - 1 ) + printhexaRec ( n - 2 ) + printhexaRec ( n - 3 ) + printhexaRec ( n - 4 ) + printhexaRec ( n - 5 ) + printhexaRec ( n - 6 ) ) ; } static void printhexa ( int n ) { System . out . print ( printhexaRec ( n ) + \\\"\\n\\\"); } public static void main ( String [ ] args ) { int n = 11 ; printhexa ( n ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Extract Leaves of a Binary Tree in a Doubly Linked List | C program to extract leaves of a Binary Tree in a Doubly Linked List ; Structure for tree and linked list ; Main function which extracts all leaves from given Binary Tree . The function returns new root of Binary Tree ( Note that root may changeif Binary Tree has only one node ) . The function also sets * head_ref as head of doubly linked list . left pointer of tree is used as prev in DLL and right pointer is used as next ; Utility function for allocating node for Binary Tree . ; Utility function for printing tree in In - Order . ; Utility function for printing double linked list . ; Driver program to test above function\\\"\\nSolution in C:\",\"targets\":\"#include \\n#include \\nstruct Node { int data ; struct Node * left , * right ; } ; struct Node * extractLeafList ( struct Node * root , struct Node * * head_ref ) { if ( root == NULL ) return NULL ; if ( root -> left == NULL && root -> right == NULL ) { root -> right = * head_ref ; if ( * head_ref != NULL ) ( * head_ref ) -> left = root ; return NULL ; } root -> right = extractLeafList ( root -> right , head_ref ) ; root -> left = extractLeafList ( root -> left , head_ref ) ; return root ; } struct Node * newNode ( int data ) { struct Node * node = ( struct Node * ) malloc ( sizeof ( struct Node ) ) ; node -> data = data ; node -> left = node -> right = NULL ; return node ; } void print ( struct Node * root ) { if ( root != NULL ) { print ( root -> left ) ; printf ( \\\" % d ▁ \\\" , root -> data ) ; print ( root -> right ) ; } } void printList ( struct Node * head ) { while ( head ) { printf ( \\\" % d ▁ \\\" , head -> data ) ; head = head -> right ; } } int main ( ) { struct Node * head = NULL ; struct Node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> left -> left = newNode ( 4 ) ; root -> left -> right = newNode ( 5 ) ; root -> right -> right = newNode ( 6 ) ; root -> left -> left -> left = newNode ( 7 ) ; root -> left -> left -> right = newNode ( 8 ) ; root -> right -> right -> left = newNode ( 9 ) ; root -> right -> right -> right = newNode ( 10 ) ; printf ( \\\" Inorder ▁ Trvaersal ▁ of ▁ given ▁ Tree ▁ is : \\n \\\" ) ; print ( root ) ; root = extractLeafList ( root , & head ) ; printf ( \\\" Extracted Double Linked list is : \\\" printList ( head ) ; printf ( \\\" Inorder traversal of modified tree is : \\\" print ( root ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Lucky Numbers | ; Returns 1 if n is a lucky no . ohterwise returns 0 ; variable next_position is just for readability of the program we can remove it and use n only ; calculate next position of input no ; Driver function to test above function\\\"\\nSolution in C:\",\"targets\":\"#include \\n#define bool int\\nbool isLucky ( int n ) { static int counter = 2 ; int next_position = n ; if ( counter > n ) return 1 ; if ( n % counter == 0 ) return 0 ; next_position -= next_position \\/ counter ; counter ++ ; return isLucky ( next_position ) ; } int main ( ) { int x = 5 ; if ( isLucky ( x ) ) printf ( \\\" % d ▁ is ▁ a ▁ lucky ▁ no . \\\" , x ) ; else printf ( \\\" % d ▁ is ▁ not ▁ a ▁ lucky ▁ no . \\\" , x ) ; getchar ( ) ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Convert an unbalanced bracket sequence to a balanced sequence | C ++ implementation of the approach ; Function to return balancedBrackets string ; Initializing dep to 0 ; Stores maximum negative depth ; if dep is less than minDep ; if minDep is less than 0 then there is need to add ' ( ' at the front ; Reinitializing to check the updated string ; if dep is not 0 then there is need to add ' ) ' at the back ; Driver code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; string balancedBrackets ( string str ) { int dep = 0 ; int minDep = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str [ i ] == ' ( ' ) dep ++ ; else dep -- ; if ( minDep > dep ) minDep = dep ; } if ( minDep < 0 ) { for ( int i = 0 ; i < abs ( minDep ) ; i ++ ) str = ' ( ' + str ; } dep = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str [ i ] == ' ( ' ) dep ++ ; else dep -- ; } if ( dep != 0 ) { for ( int i = 0 ; i < dep ; i ++ ) str = str + ' ) ' ; } return str ; } int main ( ) { string str = \\\" ) ) ) ( ) \\\" ; cout << balancedBrackets ( str ) ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Largest and Smallest N | Function to return the largest N - digit number in Hexa - Decimal Number System ; Append ' F ' N times \\\" a \\\" . repeat ( 10 ) ; Function to return the smallest N - digit number in Hexa - Decimal Number System ; Append '0' ( N - 1 ) times to 1 ; Function to print the largest and smallest N - digit Hexa - Decimal number ; Driver code\\\"\\nSolution in Javascript:\",\"targets\":\"function findLargest ( N ) { var largest = \\\" \\\" . repeat ( N ) ; return largest ; } function findSmallest ( N ) { var smallest = \\\" \\\" + \\\" \\\" . repeat ( N - 1 ) ; return smallest ; } function print ( largest ) { document . write ( \\\" \\\" + findLargest ( largest ) + \\\" \\\" ) ; document . write ( \\\" \\\" + findSmallest ( largest ) + \\\" \\\" ) ; } var N = 4 ; print ( N ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Sort 3 Integers without using if condition or using only max ( ) function | Python3 program to print three numbers in sorted order using max function ; Find maximum element ; Find minimum element ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def printSorted ( a , b , c ) :\\n\\tget_max = max ( a , max ( b , c ) )\\n\\tget_min = - max ( - a , max ( - b , - c ) )\\n\\tget_mid = ( a + b + c ) - ( get_max + get_min )\\n\\tprint ( get_min , \\\" ▁ \\\" , get_mid , \\\" ▁ \\\" , get_max )\\na , b , c = 4 , 1 , 9\\nprintSorted ( a , b , c )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Minimize K to let Person A consume at least ceil ( N \\/ ( M + 1 ) ) candies based on given rules | Java program for the above approach ; Function to check if the value of mid gives at least ( N \\/ ( M + 1 ) ) candies or not ; Candies taken by 1 st person is minimum of K and candies left ; Traverse the given array ; Amount consumed by person j ; Update the count of candies ; Check if person 1 gets the good share of candies ; Function to find minimum value of K such that the first person gets at least ( N \\/ ( M + 1 ) ) candies ; Find the minimum required value of candies for the first person ; Iterate until low is less than or equal to mid ; Find the value of mid ; Check for mid , whether it can be the possible value of K or not ; Update the value of hi ; Otherwise , update the value of lo ; Print the resultant minimum value of K ; Driver Code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { static boolean check ( int K , int n , int m , ArrayList < Integer > arr , int good_share ) { int candies = n , taken = 0 ; while ( candies > 0 ) { taken += Math . min ( K , candies ) ; candies -= Math . min ( K , candies ) ; for ( int j = 0 ; j < m ; j ++ ) { int consume = ( arr . get ( j ) * candies ) \\/ 100 ; candies -= consume ; } } return ( taken >= good_share ) ; } static void minimumK ( ArrayList < Integer > arr , int N , int M ) { int good_share = ( int ) Math . ceil ( ( N * 1.0 ) \\/ ( ( M + 1 ) * 1.0 ) ) ; int lo = 1 , hi = N ; while ( lo < hi ) { int mid = ( lo + hi ) \\/ 2 ; if ( check ( mid , N , M , arr , good_share ) ) { hi = mid ; } else { lo = mid + 1 ; } } System . out . print ( hi ) ; } public static void main ( String [ ] args ) { int N = 13 , M = 1 ; ArrayList < Integer > arr = new ArrayList < Integer > ( ) ; arr . add ( 50 ) ; minimumK ( arr , N , M ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Number of values of b such that a = b + ( a ^ b ) | function to return the number of solutions ; check for every possible value ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function countSolutions ( $ a ) { $ count = 0 ; for ( $ i = 0 ; $ i <= $ a ; $ i ++ ) { if ( $ a == ( $ i + ( $ a ^ $ i ) ) ) $ count ++ ; } return $ count ; } $ a = 3 ; echo countSolutions ( $ a ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Check if N can be represented as sum of integers chosen from set { A , B } | Java program to find if number N can be represented as sum of a ' s ▁ and ▁ b ' s ; Function to find if number N can be represented as sum of a ' s ▁ and ▁ b ' s ; base condition ; if x is already visited ; set x as possible ; recursive call ; Driver program\\\"\\nSolution in Java:\",\"targets\":\"import java . util . * ; class solution { static void checkIfPossibleRec ( int x , int a , int b , boolean isPossible [ ] , int n ) { if ( x > n ) return ; if ( isPossible [ x ] ) return ; isPossible [ x ] = true ; checkIfPossibleRec ( x + a , a , b , isPossible , n ) ; checkIfPossibleRec ( x + b , a , b , isPossible , n ) ; } static boolean checkPossible ( int n , int a , int b ) { boolean isPossible [ ] = new boolean [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) isPossible [ i ] = false ; checkIfPossibleRec ( 0 , a , b , isPossible , n ) ; return isPossible [ n ] ; } public static void main ( String args [ ] ) { int a = 3 , b = 7 , n = 8 ; if ( checkPossible ( a , b , n ) ) System . out . print ( \\\" Yes \\\" ) ; else System . out . print ( \\\" No \\\" ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Program to find the head start in a race | C ++ implementation of above approach ; Function to find the B start to C ; When B completed it 's 100 meter then Completed meters by C is ; Driver Code . ; When A completed it 's 100 meter Then completed meters of B and C is\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int Race ( int B , int C ) { int result = 0 ; result = ( ( C * 100 ) \\/ B ) ; return 100 - result ; } int main ( ) { int B = 10 , C = 28 ; B = 100 - B ; C = 100 - C ; cout << Race ( B , C ) << \\\" ▁ meters \\\" ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Difference between Insertion sort and Selection sort | Function to sort an array using insertion sort ; Move elements of arr [ 0. . i - 1 ] , that are greater than key to one position ahead of their current position ; Function to print an array of size N ; Print the array ; Driver Code ; Function Call\\\"\\nSolution in Python:\",\"targets\":\"def insertionSort ( arr , n ) :\\n\\ti = 0\\n\\tkey = 0\\n\\tj = 0\\n\\tfor i in range ( 1 , n , 1 ) :\\n\\t\\tkey = arr [ i ]\\n\\t\\tj = i - 1\\n\\t\\twhile ( j >= 0 and arr [ j ] > key ) :\\n\\t\\t\\tarr [ j + 1 ] = arr [ j ]\\n\\t\\t\\tj = j - 1\\n\\t\\tarr [ j + 1 ] = key\\ndef printArray ( arr , n ) :\\n\\ti = 0\\n\\tfor i in range ( n ) :\\n\\t\\tprint ( arr [ i ] , end = \\\" ▁ \\\" )\\n\\tprint ( \\\" \\\" , end ▁ = ▁ \\\" \\\" )\\nif __name__ == ' _ _ main _ _ ' :\\n\\tarr = [ 12 , 11 , 13 , 5 , 6 ]\\n\\tN = len ( arr )\\n\\tinsertionSort ( arr , N )\\n\\tprintArray ( arr , N )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"Palindrome Partitioning | DP | Dynamic Programming Solution for Palindrome Partitioning Problem ; Returns the minimum number of cuts needed to partition a string such that every part is a palindrome ; Get the length of the string ; Create two arrays to build the solution in bottom up manner C [ i ] [ j ] = Minimum number of cuts needed for palindrome partitioning of substring str [ i . . j ] P [ i ] [ j ] = true if substring str [ i . . j ] is palindrome , else false Note that C [ i ] [ j ] is 0 if P [ i ] [ j ] is true ; different looping variables ; Every substring of length 1 is a palindrome ; L is substring length . Build the solution in bottom up manner by considering all substrings of length starting from 2 to n . The loop structure is same as Matrix Chain Multiplication problem ( See https : www . geeksforgeeks . org \\/ matrix - chain - multiplication - dp - 8 \\/ ) ; For substring of length L , set different possible starting indexes ; Set ending index ; If L is 2 , then we just need to compare two characters . Else need to check two corner characters and value of P [ i + 1 ] [ j - 1 ] ; IF str [ i . . j ] is palindrome , then C [ i ] [ j ] is 0 ; Make a cut at every possible location starting from i to j , and get the minimum cost cut . ; Return the min cut value for complete string . i . e . , str [ 0. . n - 1 ] ; Driver program to test above function\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#include \\n#include \\nint min ( int a , int b ) { return ( a < b ) ? a : b ; } int minPalPartion ( char * str ) { int n = strlen ( str ) ; int C [ n ] [ n ] ; bool P [ 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 [ i ] == str [ j ] ) ; else P [ i ] [ j ] = ( str [ i ] == str [ j ] ) && P [ i + 1 ] [ j - 1 ] ; if ( P [ i ] [ j ] == true ) C [ i ] [ j ] = 0 ; else { C [ i ] [ j ] = INT_MAX ; for ( k = i ; k <= j - 1 ; k ++ ) C [ i ] [ j ] = min ( C [ i ] [ j ] , C [ i ] [ k ] + C [ k + 1 ] [ j ] + 1 ) ; } } } return C [ 0 ] [ n - 1 ] ; } int main ( ) { char str [ ] = \\\" ababbbabbababa \\\" ; printf ( \\\" Min ▁ cuts ▁ needed ▁ for ▁ Palindrome ▁ Partitioning ▁ is ▁ % d \\\" , minPalPartion ( str ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Find the most frequent digit without using array \\/ string | Simple function to count occurrences of digit d in x ; Initialize count of digit d ; Increment count if current digit is same as d ; Returns the max occurring digit in x ; Handle negative number ; Traverse through all digits ; Count occurrences of current digit ; Update max_count and result if needed ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function countOccurrences ( $ x , $ d ) { $ count = 0 ; while ( $ x ) { if ( $ x % 10 == $ d ) $ count ++ ; $ x = ( int ) ( $ x \\/ 10 ) ; } return $ count ; } function maxOccurring ( $ x ) { if ( $ x < 0 ) $ x = - $ x ; for ( $ d = 0 ; $ d <= 9 ; $ d ++ ) { $ count = countOccurrences ( $ x , $ d ) ; if ( $ count >= $ max_count ) { $ max_count = $ count ; $ result = $ d ; } } return $ result ; } $ x = 1223355 ; echo \\\" Max ▁ occurring ▁ digit ▁ is ▁ \\\" . maxOccurring ( $ x ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Find if there is a path between two vertices in an undirected graph | C ++ program to check if there is exist a path between two vertices of an undirected graph . ; function to add an edge to graph ; A BFS based function to check whether d is reachable from s . ; Base case ; Mark all the vertices as not visited ; Create a queue for BFS ; Mark the current node as visited and enqueue it ; Dequeue a vertex from queue and print it ; Get all adjacent vertices of the dequeued vertex s If a adjacent has not been visited , then mark it visited and enqueue it ; If this adjacent node is the destination node , then return true ; Else , continue to do BFS ; If BFS is complete without visiting d ; Driver program to test methods of graph class ; Create a graph in the above diagram\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; vector < vector < int > > adj ; void addEdge ( int v , int w ) { adj [ v ] . push_back ( w ) ; adj [ w ] . push_back ( v ) ; } bool isReachable ( int s , int d ) { if ( s == d ) return true ; int n = ( int ) adj . size ( ) ; vector < bool > visited ( n , false ) ; queue < int > q ; visited [ s ] = true ; q . push ( s ) ; while ( ! q . empty ( ) ) { s = q . front ( ) ; q . pop ( ) ; for ( auto x : adj [ s ] ) { if ( x == d ) return true ; if ( ! visited [ x ] ) { visited [ x ] = true ; q . push ( x ) ; } } } return false ; } int main ( ) { int n = 4 ; adj = vector < vector < int > > ( n ) ; addEdge ( 0 , 1 ) ; addEdge ( 0 , 2 ) ; addEdge ( 1 , 2 ) ; addEdge ( 2 , 0 ) ; addEdge ( 2 , 3 ) ; addEdge ( 3 , 3 ) ; int u = 1 , v = 3 ; if ( isReachable ( u , v ) ) cout << \\\" There is a path from \\\" ▁ < < ▁ u ▁ < < ▁ \\\" to \\\" ▁ < < ▁ v ; \\n \\t else \\n \\t \\t cout ▁ < < ▁ \\\" There is no path from \\\" ▁ < < ▁ u ▁ < < ▁ \\\" to \\\" return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Smallest power of 2 greater than or equal to n | PHP program to find smallest power of 2 greater than or equal to n ; First n in the below condition is for the case where n is 0 ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function nextPowerOf2 ( $ n ) { $ count = 0 ; if ( $ n && ! ( $ n & ( $ n - 1 ) ) ) return $ n ; while ( $ n != 0 ) { $ n >>= 1 ; $ count += 1 ; } return 1 << $ count ; } $ n = 0 ; echo ( nextPowerOf2 ( $ n ) ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Counts paths from a point to reach Origin | Function to find binomial Coefficient ; Constructing Pascal 's Triangle ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def binomialCoeff ( n , k ) :\\n\\tC = [ 0 ] * ( k + 1 )\\n\\tC [ 0 ] = 1\\n\\tfor i in range ( 1 , n + 1 ) :\\n\\t\\tj = min ( i , k )\\n\\t\\twhile ( j > 0 ) :\\n\\t\\t\\tC [ j ] = C [ j ] + C [ j - 1 ]\\n\\t\\t\\tj -= 1\\n\\treturn C [ k ]\\nn = 3\\nm = 2\\nprint ( \\\" Number ▁ of ▁ Paths : \\\" , binomialCoeff ( n + m , n ) )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Count words in a given string | C program to count no of words from given input string . ; returns number of words in str ; word count ; Scan all characters one by one ; If next character is a separator , set the state as OUT ; If next character is not a word separator and state is OUT , then set the state as IN and increment word count ; Move to next character ; Driver program to tes above functions\\\"\\nSolution in C:\",\"targets\":\"#include \\n#define OUT \\t0\\n#define IN \\t1\\nunsigned countWords ( char * str ) { int state = OUT ; unsigned wc = 0 ; while ( * str ) { if ( * str == ' ▁ ' * str == ' ' * str == ' \\t ' ) state = OUT ; else if ( state == OUT ) { state = IN ; ++ wc ; } ++ str ; } return wc ; } int main ( void ) { char str [ ] = \\\" One ▁ two \\t \\t three \\n \\t four \\t five ▁ \\\" ; printf ( \\\" No ▁ of ▁ words ▁ : ▁ % u \\\" , countWords ( str ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Smallest power of 2 greater than or equal to n | C program to find smallest power of 2 greater than or equal to n ; First n in the below condition is for the case where n is 0 ; Driver Code\\\"\\nSolution in C:\",\"targets\":\"#include \\nunsigned int nextPowerOf2 ( unsigned int n ) { unsigned count = 0 ; if ( n && ! ( n & ( n - 1 ) ) ) return n ; while ( n != 0 ) { n >>= 1 ; count += 1 ; } return 1 << count ; } int main ( ) { unsigned int n = 0 ; printf ( \\\" % d \\\" , nextPowerOf2 ( n ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Minimum number of given operations required to reduce the array to 0 element | Function to return the minimum operations required ; Count the frequency of each element ; Maximum element from the array ; Find all the multiples of i ; Delete the multiples ; Increment the operations ; Driver code\\\"\\nSolution in Javascript:\",\"targets\":\"function minOperations ( arr , n ) { let maxi , result = 0 ; let freq = new Array ( 1000001 ) . fill ( 0 ) ; for ( let i = 0 ; i < n ; i ++ ) { let x = arr [ i ] ; freq [ x ] ++ ; } maxi = Math . max ( ... arr ) ; for ( let i = 1 ; i <= maxi ; i ++ ) { if ( freq [ i ] != 0 ) { for ( let j = i * 2 ; j <= maxi ; j = j + i ) { freq [ j ] = 0 ; } result ++ ; } } return result ; } let arr = [ 2 , 4 , 2 , 4 , 4 , 4 ] ; let n = arr . length ; document . write ( minOperations ( arr , n ) ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Find the minimum of maximum length of a jump required to reach the last island in exactly k jumps | Java implementation of the approach ; Function that returns true if it is possible to reach end of the array in exactly k jumps ; Variable to store the number of steps required to reach the end ; If it is possible to reach the end in exactly k jumps ; Returns the minimum maximum distance required to reach the end of the array in exactly k jumps ; Stores the answer ; Binary search to calculate the result ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"class GFG { static boolean isPossible ( int arr [ ] , int n , int dist , int k ) { int req = 0 ; int curr = 0 ; int prev = 0 ; for ( int i = 0 ; i < n ; i ++ ) { while ( curr != n && arr [ curr ] - arr [ prev ] <= dist ) { curr ++ ; } req ++ ; if ( curr == n ) { break ; } prev = curr - 1 ; } if ( curr != n ) { return false ; } if ( req <= k ) { return true ; } return false ; } static int minDistance ( int arr [ ] , int n , int k ) { int l = 0 ; int h = arr [ n - 1 ] ; int ans = 0 ; while ( l <= h ) { int m = ( l + h ) \\/ 2 ; if ( isPossible ( arr , n , m , k ) ) { ans = m ; h = m - 1 ; } else { l = m + 1 ; } } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 15 , 36 , 43 } ; int n = arr . length ; int k = 2 ; System . out . println ( minDistance ( arr , n , k ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Sum of all Subarrays | Set 1 | Computes sum all sub - array ; Pick starting point ; Pick ending point ; sum subarray between current starting and ending points ; driver program\\\"\\nSolution in Python:\",\"targets\":\"def SubArraySum ( arr , n ) :\\n\\ttemp , result = 0 , 0\\n\\tfor i in range ( 0 , n ) :\\n\\t\\ttemp = 0 ;\\n\\t\\tfor j in range ( i , n ) :\\n\\t\\t\\ttemp += arr [ j ]\\n\\t\\t\\tresult += temp\\n\\treturn result\\narr = [ 1 , 2 , 3 ]\\nn = len ( arr )\\nprint ( \\\" Sum ▁ of ▁ SubArray ▁ : \\\" , SubArraySum ( arr , n ) )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Sum of all proper divisors of a natural number | Function to calculate sum of all proper divisors num -- > given natural number ; Final result of summation of divisors ; find all divisors which divides ' num ' ; if ' i ' is divisor of ' num ' ; if both divisors are same then add it only once else add both ; Add 1 to the result as 1 is also a divisor ; Driver program to run the case\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function divSum ( num ) { let result = 0 ; for ( let i = 2 ; i <= Math . sqrt ( num ) ; i ++ ) { if ( num % i == 0 ) { if ( i == ( num \\/ i ) ) result += i ; else result += ( i + num \\/ i ) ; } } return ( result + 1 ) ; } let num = 36 ; document . write ( divSum ( num ) ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Longest substring such that no three consecutive characters are same | Java implementation of the approach ; Function to return the length of the longest substring such that no three consecutive characters are same ; If the length of the given string is less than 3 ; Initialize temporary and final ans to 2 as this is the minimum length of substring when length of the given string is greater than 2 ; Traverse the string from the third character to the last ; If no three consecutive characters are same then increment temporary count ; Else update the final ans and reset the temporary count ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"import java . util . * ; class GFG { static int maxLenSubStr ( String s ) { if ( s . length ( ) < 3 ) return s . length ( ) ; int temp = 2 ; int ans = 2 ; for ( int i = 2 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( i - 1 ) || s . charAt ( i ) != s . charAt ( i - 2 ) ) temp ++ ; else { ans = Math . max ( temp , ans ) ; temp = 2 ; } } ans = Math . max ( temp , ans ) ; return ans ; } public static void main ( String [ ] args ) { String s = \\\" baaabbabbb \\\" ; System . out . println ( maxLenSubStr ( s ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Binary Insertion Sort | iterative implementation ; Function to sort an array a [ ] of size ' n ' ; find location where selected should be inseretd ; Move all elements after location to create space ; Driver Code\\\"\\nSolution in C:\",\"targets\":\"#include \\nint binarySearch ( int a [ ] , int item , int low , int high ) { while ( low <= high ) { int mid = low + ( high - low ) \\/ 2 ; if ( item == a [ mid ] ) return mid + 1 ; else if ( item > a [ mid ] ) low = mid + 1 ; else high = mid - 1 ; } return low ; } void insertionSort ( int a [ ] , int n ) { int i , loc , j , k , selected ; for ( i = 1 ; i < n ; ++ i ) { j = i - 1 ; selected = a [ i ] ; loc = binarySearch ( a , selected , 0 , j ) ; while ( j >= loc ) { a [ j + 1 ] = a [ j ] ; j -- ; } a [ j + 1 ] = selected ; } } int main ( ) { int a [ ] = { 37 , 23 , 0 , 17 , 12 , 72 , 31 , 46 , 100 , 88 , 54 } ; int n = sizeof ( a ) \\/ sizeof ( a [ 0 ] ) , i ; insertionSort ( a , n ) ; printf ( \\\" Sorted ▁ array : ▁ \\n \\\" ) ; for ( i = 0 ; i < n ; i ++ ) printf ( \\\" % d ▁ \\\" , a [ i ] ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Maximum sum in circular array such that no two elements are adjacent | Function to calculate the sum from 0 th position to ( n - 2 ) th position ; copy the element of original array to dp [ ] ; find the maximum element in the array ; start from 2 nd to n - 1 th pos ; traverse for all pairs bottom - up approach ; dp - condition ; find maximum sum ; return the maximum ; Function to find the maximum sum from 1 st position to n - 1 - th position ; Traverse from third to n - th pos ; bootom - up approach ; dp condition ; find max sum ; return max ; Driver Code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function maxSum1 ( arr , n ) { let dp = new Array ( n ) ; let maxi = 0 ; for ( i = 0 ; i < n - 1 ; i ++ ) { dp [ i ] = arr [ i ] ; if ( maxi < arr [ i ] ) maxi = arr [ i ] ; } for ( i = 2 ; i < n - 1 ; i ++ ) { for ( j = 0 ; j < i - 1 ; j ++ ) { if ( dp [ i ] < dp [ j ] + arr [ i ] ) { dp [ i ] = dp [ j ] + arr [ i ] ; if ( maxi < dp [ i ] ) maxi = dp [ i ] ; } } } return maxi ; } function maxSum2 ( arr , n ) { let dp = new Array ( n ) ; let maxi = 0 ; for ( i = 1 ; i < n ; i ++ ) { dp [ i ] = arr [ i ] ; if ( maxi < arr [ i ] ) maxi = arr [ i ] ; } for ( i = 3 ; i < n ; i ++ ) { for ( j = 1 ; j < i - 1 ; j ++ ) { if ( dp [ i ] < arr [ i ] + dp [ j ] ) { dp [ i ] = arr [ i ] + dp [ j ] ; if ( maxi < dp [ i ] ) maxi = dp [ i ] ; } } } return maxi ; } function findMaxSum ( arr , n ) { let t = Math . max ( maxSum1 ( arr , n ) , maxSum2 ( arr , n ) ) ; return t ; } let arr = [ 1 , 2 , 3 , 1 ] ; let n = arr . length ; document . write ( findMaxSum ( arr , n ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"LCM of unique elements present in an array | Function to find GCD of two numbers ; Base Case ; Recursively find the GCD ; Function to find LCM of two numbers ; Function to find LCM of unique elements present in the array ; Stores the frequency of each number of the array ; Store the frequency of each element of the array ; Store the required result ; Traverse the map freq ; If the frequency of the current element is 1 , then update ans ; If there is no unique element , set lcm to - 1 ; Print the result ; Driver Code ; Function Call\\\"\\nSolution in Javascript:\",\"targets\":\"function findGCD ( a , b ) { if ( b == 0 ) return a ; return findGCD ( b , a % b ) ; } function findLCM ( a , b ) { return ( a * b ) \\/ findGCD ( a , b ) ; } function uniqueElementsLCM ( arr , N ) { var freq = new Map ( ) ; for ( var i = 0 ; i < N ; i ++ ) { if ( freq . has ( arr [ i ] ) ) { freq . set ( arr [ i ] , freq . get ( arr [ i ] ) + 1 ) ; } else { freq . set ( arr [ i ] , 1 ) ; } } var lcm = 1 ; freq . forEach ( ( value , key ) => { if ( value == 1 ) { lcm = findLCM ( lcm , key ) ; } } ) ; if ( lcm == 1 ) lcm = - 1 ; document . write ( lcm ) ; } var arr = [ 1 , 2 , 1 , 3 , 3 , 4 ] ; var N = arr . length ; uniqueElementsLCM ( arr , N ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Replace every character of string by character whose ASCII value is K times more than it | Function to move string character ; changed string ; iterate for every characters ; ASCII value ; store the duplicate ; if k - th ahead character exceed ' z ' ; print the new string ; Driver code ; function call\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function encode ( $ s , $ k ) { $ newS = \\\" \\\" ; for ( $ i = 0 ; $ i < strlen ( $ s ) ; ++ $ i ) { $ val = ord ( $ s [ $ i ] ) ; $ dup = $ k ; if ( $ val + $ k > 122 ) { $ k -= ( 122 - $ val ) ; $ k = $ k % 26 ; $ newS = $ newS . chr ( 96 + $ k ) ; } else $ newS = $ newS . chr ( $ val + $ k ) ; $ k = $ dup ; } echo $ newS ; } $ str = \\\" abc \\\" ; $ k = 28 ; encode ( $ str , $ k ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Length of longest subset consisting of A 0 s and B 1 s from an array of strings | Set 2 | Java program for the above approach ; Function to find the length of the longest subset of an array of strings with at most A 0 s and B 1 s ; Initialize a 2D array with its entries as 0 ; Traverse the given array ; Store the count of 0 s and 1 s in the current string ; Iterate in the range [ A , zeros ] ; Iterate in the range [ B , ones ] ; Update the value of dp [ i ] [ j ] ; Print the result ; Driver Code\\\"\\nSolution in Java:\",\"targets\":\"import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static int MaxSubsetlength ( String arr [ ] , int A , int B ) { int dp [ ] [ ] = new int [ A + 1 ] [ B + 1 ] ; for ( String str : arr ) { int zeros = 0 , ones = 0 ; for ( char ch : str . toCharArray ( ) ) { if ( ch == '0' ) zeros ++ ; else ones ++ ; } for ( int i = A ; i >= zeros ; i -- ) for ( int j = B ; j >= ones ; j -- ) dp [ i ] [ j ] = Math . max ( dp [ i ] [ j ] , dp [ i - zeros ] [ j - ones ] + 1 ) ; } return dp [ A ] [ B ] ; } public static void main ( String [ ] args ) { String arr [ ] = { \\\"1\\\" , \\\"0\\\" , \\\"0001\\\" , \\\"10\\\" , \\\"111001\\\" } ; int A = 5 , B = 3 ; System . out . println ( MaxSubsetlength ( arr , A , B ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Find Bit whose minimum sequence flips makes all bits same | Function to check which bit is to be flipped ; variable to store first and last character of string ; Check if first and last characters are equal , if yes , then return the character which is not at last ; else return last ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function bitToBeFlipped ( $ s ) { $ last = $ s [ strlen ( $ s ) - 1 ] ; $ first = $ s [ 0 ] ; if ( $ last == $ first ) { if ( $ last == '0' ) { return '1' ; } else { return '0' ; } } else if ( $ last != $ first ) { return $ last ; } } $ s = \\\"1101011000\\\" ; echo bitToBeFlipped ( $ s ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Swap nodes in a linked list without swapping data | JavaScript program to swap two given nodes of a linked list ; head of list ; Function to swap Nodes x and y in linked list by changing links ; Nothing to do if x and y are same ; Search for x ( keep track of prevX and CurrX ) ; Search for y ( keep track of prevY and currY ) ; If either x or y is not present , nothing to do ; If x is not head of linked list ; make y the new head ; If y is not head of linked list ; make x the new head ; Swap next pointers ; Function to add Node at beginning of list . ; 1. alloc the Node and put the data ; 2. Make next of new Node as head ; 3. Move the head to point to new Node ; This function prints contents of linked list starting from the given Node ; The constructed linked list is : 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7\\\"\\nHow can the above be solved in JS?\",\"targets\":\"class Node { constructor ( val ) { this . data = val ; this . next = null ; } } var head ; function swapNodes ( x , y ) { if ( x == y ) return ; var prevX = null , currX = head ; while ( currX != null && currX . data != x ) { prevX = currX ; currX = currX . next ; } var prevY = null , currY = head ; while ( currY != null && currY . data != y ) { prevY = currY ; currY = currY . next ; } if ( currX == null currY == null ) return ; if ( prevX != null ) prevX . next = currY ; else head = currY ; if ( prevY != null ) prevY . next = currX ; else head = currX ; var temp = currX . next ; currX . next = currY . next ; currY . next = temp ; } function push ( new_data ) { var new_Node = new Node ( new_data ) ; new_Node . next = head ; head = new_Node ; } function printList ( ) { var tNode = head ; while ( tNode != null ) { document . write ( tNode . data + \\\" \\\" ) ; tNode = tNode . next ; } } push ( 7 ) ; push ( 6 ) ; push ( 5 ) ; push ( 4 ) ; push ( 3 ) ; push ( 2 ) ; push ( 1 ) ; document . write ( \\\" \\\" ) ; printList ( ) ; swapNodes ( 4 , 3 ) ; document . write ( \\\" \\\" ) ; printList ( ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Print sorted distinct elements of array | C # program to print sorted distinct elements . ; Create a set using array elements ; Print contents of the set . ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; using System . Collections . Generic ; using System . Linq ; class GFG { static void printRepeating ( int [ ] arr , int size ) { SortedSet < int > s = new SortedSet < int > ( arr ) ; foreach ( var n in s ) { Console . Write ( n + \\\" ▁ \\\" ) ; } } public static void Main ( ) { int [ ] arr = { 1 , 3 , 2 , 2 , 1 } ; int n = arr . Length ; printRepeating ( arr , n ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Print list items containing all characters of a given word | Java program to print all strings that contain all characters of a word ; prints list items having all characters of word ; * Since calloc is used , map [ ] is initialized as 0 ; Set the values in map ; Get the length ( ) of given word ; * Check each item of list if has all characters of word ; * unset the bit so that strings like sss not printed ; Set the values in map for next item ; Driver code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"class GFG { static final int NO_OF_CHARS = 256 ; static void print ( String [ ] list , String word , int list_size ) { int [ ] map = new int [ NO_OF_CHARS ] ; int i , j , count , word_size ; for ( i = 0 ; i < word . length ( ) ; i ++ ) map [ word . charAt ( i ) ] = 1 ; word_size = word . length ( ) ; for ( i = 0 ; i < list_size ; i ++ ) { for ( j = 0 , count = 0 ; j < list [ i ] . length ( ) ; j ++ ) { if ( map [ list [ i ] . charAt ( j ) ] > 0 ) { count ++ ; map [ list [ i ] . charAt ( j ) ] = 0 ; } } if ( count == word_size ) System . out . println ( list [ i ] ) ; for ( j = 0 ; j < word . length ( ) ; j ++ ) map [ word . charAt ( j ) ] = 1 ; } } public static void main ( String [ ] args ) { String str = \\\" sun \\\" ; String [ ] list = { \\\" geeksforgeeks \\\" , \\\" unsorted \\\" , \\\" sunday \\\" , \\\" just \\\" , \\\" sss \\\" } ; print ( list , str , 5 ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"An efficient way to check whether n | A simple PHP program to check if n - th Fibonacci number is multiple of 10. ; Returns true if n - th Fibonacci number is multiple of 10. ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function fibonacci ( $ n ) { $ a = 0 ; $ b = 1 ; $ c ; if ( $ n <= 1 ) return $ n ; for ( $ i = 2 ; $ i <= $ n ; $ i ++ ) { $ c = $ a + $ b ; $ a = $ b ; $ b = $ c ; } return $ c ; } function isMultipleOf10 ( $ n ) { $ f = fibonacci ( 30 ) ; return ( $ f % 10 == 0 ) ; } $ n = 30 ; if ( isMultipleOf10 ( $ n ) ) echo \\\" Yes \\n \\\" ; else echo \\\" No \\n \\\" ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Program to find the Encrypted word | Function to find the encrypted string ; to store the encrypted string ; after ' z ' , it should go to a . ; Driver code\\\"\\nSolution in Python:\",\"targets\":\"def findWord ( c , n ) :\\n\\tco = 0\\n\\ts = [ 0 ] * n\\n\\tfor i in range ( n ) :\\n\\t\\tif ( i < n \\/ 2 ) :\\n\\t\\t\\tco += 1\\n\\t\\telse :\\n\\t\\t\\tco = n - i\\n\\t\\tif ( ord ( c [ i ] ) + co <= 122 ) :\\n\\t\\t\\ts [ i ] = chr ( ord ( c [ i ] ) + co )\\n\\t\\telse :\\n\\t\\t\\ts [ i ] = chr ( ord ( c [ i ] ) + co - 26 )\\n\\tprint ( * s , sep = \\\" \\\" )\\ns = \\\" abcd \\\"\\nfindWord ( s , len ( s ) )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Largest palindromic number by permuting digits | function to check if a number can be permuted to form a palindrome number ; counts the occurrence of number which is odd ; if occurrence is odd ; if number exceeds 1 ; function to print the largest palindromic number by permuting digits of a number ; string length ; map that marks the occurrence of a number ; check the possibility of a palindromic number ; string array that stores the largest permuted palindromic number ; pointer of front ; greedily start from 9 to 0 and place the greater number in front and odd in the middle ; if the occurrence of number is odd ; place one odd occurring number in the middle ; decrease the count ; place the rest of numbers greedily ; if all numbers occur even times , then place greedily ; place greedily at front ; 2 numbers are placed , so decrease the count ; increase placing position ; print the largest string thus formed ; driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function possibility ( m , length , s ) { var countodd = 0 ; for ( var i = 0 ; i < length ; i ++ ) { if ( m . get ( s . charCodeAt ( i ) - 48 ) & 1 ) countodd ++ ; if ( countodd > 1 ) return false ; } return true ; } function largestPalindrome ( s ) { var l = s . length ; var m = new Map ( ) ; for ( var i = 0 ; i < l ; i ++ ) { if ( m . has ( s . charCodeAt ( i ) - 48 ) ) m . set ( s . charCodeAt ( i ) - 48 , m . get ( s . charCodeAt ( i ) - 48 ) + 1 ) ; else m . set ( s . charCodeAt ( i ) - 48 , 1 ) ; } if ( possibility ( m , l , s ) == false ) { document . write ( \\\" \\\" ) ; return ; } var largest = new Array ( l ) ; var front = 0 ; for ( var i = 9 ; i >= 0 ; i -- ) { if ( m . has ( i ) & 1 ) { largest [ Math . floor ( l \\/ 2 ) ] = String . fromCharCode ( i + 48 ) ; m . set ( i , m . get ( i ) - 1 ) ; while ( m . get ( i ) > 0 ) { largest [ front ] = String . fromCharCode ( i + 48 ) ; largest [ l - front - 1 ] = String . fromCharCode ( i + 48 ) ; m . set ( i , m . get ( i ) - 2 ) ; front ++ ; } } else { while ( m . get ( i ) > 0 ) { largest [ front ] = String . fromCharCode ( i + 48 ) ; largest [ l - front - 1 ] = String . fromCharCode ( i + 48 ) ; m . set ( i , m . get ( i ) - 2 ) ; front ++ ; } } } for ( var i = 0 ; i < l ; i ++ ) document . write ( largest [ i ] ) ; } var s = \\\" \\\" ; largestPalindrome ( s ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Minimum number of bracket reversals needed to make an expression balanced | Returns count of minimum reversals for making expr balanced . Returns - 1 if expr cannot be balanced . ; length of expression must be even to make it balanced by using reversals . ; After this loop , stack contains unbalanced part of expression , i . e . , expression of the form \\\" . . . . \\\" ; Length of the reduced expression red_len = ( m + n ) ; count opening brackets at the end of stack ; return ceil ( m \\/ 2 ) + ceil ( n \\/ 2 ) which is actually equal to ( m + n ) \\/ 2 + n % 2 when m + n is even . ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"def countMinReversals ( expr ) :\\n\\tlenn = len ( expr )\\n\\tif ( lenn % 2 ) :\\n\\t\\treturn - 1\\n\\ts = [ ]\\n\\tfor i in range ( lenn ) :\\n\\t\\tif ( expr [ i ] == ' ' and len ( s ) ) :\\n\\t\\t\\tif ( s [ 0 ] == ' ' ) :\\n\\t\\t\\t\\ts . pop ( 0 )\\n\\t\\t\\telse :\\n\\t\\t\\t\\ts . insert ( 0 , expr [ i ] )\\n\\t\\telse :\\n\\t\\t\\ts . insert ( 0 , expr [ i ] )\\n\\tred_len = len ( s )\\n\\tn = 0\\n\\twhile ( len ( s ) and s [ 0 ] == ' ' ) :\\n\\t\\ts . pop ( 0 )\\n\\t\\tn += 1\\n\\treturn ( red_len \\/\\/ 2 + n % 2 )\\nif __name__ == ' _ _ main _ _ ' :\\n\\texpr = \\\" } } { { \\\"\\n\\tprint ( countMinReversals ( expr . strip ( ) ) )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Length of smallest subarray to be removed such that the remaining array is sorted | C ++ program for the above approach ; Find the length of the shortest subarray ; To store the result ; Calculate the possible length of the sorted subarray from left ; Array is sorted ; Calculate the possible length of the sorted subarray from left ; Update the result ; Calculate the possible length in the middle we can delete and update the result ; Update the result ; Return the result ; Driver Code ; Function call\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int findLengthOfShortestSubarray ( int arr [ ] , int N ) { int minlength = INT_MAX ; int left = 0 ; int right = N - 1 ; while ( left < right && arr [ left + 1 ] >= arr [ left ] ) { left ++ ; } if ( left == N - 1 ) return 0 ; while ( right > left && arr [ right - 1 ] <= arr [ right ] ) { right -- ; } minlength = min ( N - left - 1 , right ) ; int j = right ; for ( int i = 0 ; i < left + 1 ; i ++ ) { if ( arr [ i ] <= arr [ j ] ) { minlength = min ( minlength , j - i - 1 ) ; } else if ( j < N - 1 ) { j ++ ; } else { break ; } } return minlength ; } int main ( ) { int arr [ ] = { 6 , 3 , 10 , 11 , 15 , 20 , 13 , 3 , 18 , 12 } ; int N = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; cout << ( findLengthOfShortestSubarray ( arr , N ) ) ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Minimize count of given operations required to make two given strings permutations of each other | Java program to implement the above approach ; Function to minimize the count of operations to make str1 and str2 permutations of each other ; Store the frequency of each character of str1 ; Store the frequency of each character of str2 ; Traverse the freq1 [ ] and freq2 [ ] ; If frequency of character in str1 is greater than str2 ; Otherwise ; Store sum of freq1 [ ] ; Store sum of freq2 [ ] ; Driver Code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; import java . io . * ; import java . lang . Math ; class GFG { static int ctMinEdits ( String str1 , String str2 ) { int N1 = str1 . length ( ) ; int N2 = str2 . length ( ) ; int freq1 [ ] = new int [ 256 ] ; Arrays . fill ( freq1 , 0 ) ; for ( int i = 0 ; i < N1 ; i ++ ) { freq1 [ str1 . charAt ( i ) ] ++ ; } int freq2 [ ] = new int [ 256 ] ; Arrays . fill ( freq2 , 0 ) ; for ( int i = 0 ; i < N2 ; i ++ ) { freq2 [ str2 . charAt ( i ) ] ++ ; } for ( int i = 0 ; i < 256 ; i ++ ) { if ( freq1 [ i ] > freq2 [ i ] ) { freq1 [ i ] = freq1 [ i ] - freq2 [ i ] ; freq2 [ i ] = 0 ; } else { freq2 [ i ] = freq2 [ i ] - freq1 [ i ] ; freq1 [ i ] = 0 ; } } int sum1 = 0 ; int sum2 = 0 ; for ( int i = 0 ; i < 256 ; i ++ ) { sum1 += freq1 [ i ] ; sum2 += freq2 [ i ] ; } return Math . max ( sum1 , sum2 ) ; } public static void main ( final String [ ] args ) { String str1 = \\\" geeksforgeeks \\\" ; String str2 = \\\" geeksforcoder \\\" ; System . out . println ( ctMinEdits ( str1 , str2 ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Find a Fixed Point ( Value equal to index ) in a given array | Python program to check fixed point in an array using linear search ; If no fixed point present then return - 1 ; Driver program to check above functions\\\"\\nSolution in Python:\",\"targets\":\"def linearSearch ( arr , n ) :\\n\\tfor i in range ( n ) :\\n\\t\\tif arr [ i ] is i :\\n\\t\\t\\treturn i\\n\\treturn - 1\\narr = [ - 10 , - 1 , 0 , 3 , 10 , 11 , 30 , 50 , 100 ]\\nn = len ( arr )\\nprint ( \\\" Fixed ▁ Point ▁ is ▁ \\\" + str ( linearSearch ( arr , n ) ) )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Minimize count of given operations required to make two given strings permutations of each other | Function to minimize the count of operations to make str1 and str2 permutations of each other ; Store the frequency of each character of str1 ; Store the frequency of each character of str2 ; Traverse the freq1 [ ] and freq2 [ ] ; If frequency of character in str1 is greater than str2 ; Otherwise ; Store sum of freq1 [ ] ; Store sum of freq2 [ ] ; Driver Code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function ctMinEdits ( str1 , str2 ) { let N1 = str1 . length ; let N2 = str2 . length ; let freq1 = new Array ( 256 ) . fill ( 0 ) ; for ( let i = 0 ; i < N1 ; i ++ ) { freq1 [ str1 [ i ] . charCodeAt ( ) ] ++ ; } let freq2 = new Array ( 256 ) . fill ( 0 ) ; for ( let i = 0 ; i < N2 ; i ++ ) { freq2 [ str2 [ i ] . charCodeAt ( ) ] ++ ; } for ( let i = 0 ; i < 256 ; i ++ ) { if ( freq1 [ i ] > freq2 [ i ] ) { freq1 [ i ] = freq1 [ i ] - freq2 [ i ] ; freq2 [ i ] = 0 ; } else { freq2 [ i ] = freq2 [ i ] - freq1 [ i ] ; freq1 [ i ] = 0 ; } } let sum1 = 0 ; let sum2 = 0 ; for ( let i = 0 ; i < 256 ; i ++ ) { sum1 += freq1 [ i ] ; sum2 += freq2 [ i ] ; } return Math . max ( sum1 , sum2 ) ; } let str1 = \\\" \\\" ; let str2 = \\\" \\\" ; document . write ( ctMinEdits ( str1 . split ( ' ' ) , str2 . split ( ' ' ) ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Jaro and Jaro | Function to calculate the Jaro Similarity of two strings ; If the strings are equal ; Length of two strings ; Maximum distance upto which matching is allowed ; Count of matches ; Hash for matches ; Traverse through the first string ; Check if there is any matches ; If there is a match ; If there is no match ; Number of transpositions ; Count number of occurrences where two characters match but there is a third matched character in between the indices ; Find the next matched character in second string ; Return the Jaro Similarity ; Jaro Winkler Similarity ; If the jaro Similarity is above a threshold ; Find the length of common prefix ; If the characters match ; Else break ; Maximum of 4 characters are allowed in prefix ; Calculate jaro winkler Similarity ; Driver code ; Print Jaro - Winkler Similarity of two strings\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function jaro_distance ( s1 , s2 ) { if ( s1 == s2 ) return 1.0 ; let len1 = s1 . length , len2 = s2 . length ; if ( len1 == 0 len2 == 0 ) return 0.0 ; let max_dist = Math . floor ( Math . max ( len1 , len2 ) \\/ 2 ) - 1 ; let match = 0 ; let hash_s1 = new Array ( s1 . length ) ; hash_s1 . fill ( 0 ) ; let hash_s2 = new Array ( s2 . length ) ; hash_s2 . fill ( 0 ) ; for ( let i = 0 ; i < len1 ; i ++ ) { for ( let j = Math . max ( 0 , i - max_dist ) ; j < Math . min ( len2 , i + max_dist + 1 ) ; j ++ ) if ( s1 [ i ] == s2 [ j ] && hash_s2 [ j ] == 0 ) { hash_s1 [ i ] = 1 ; hash_s2 [ j ] = 1 ; match ++ ; break ; } } if ( match == 0 ) return 0.0 ; let t = 0 ; let point = 0 ; for ( let i = 0 ; i < len1 ; i ++ ) if ( hash_s1 [ i ] == 1 ) { while ( hash_s2 [ point ] == 0 ) point ++ ; if ( s1 [ i ] != s2 [ point ++ ] ) t ++ ; } t \\/= 2 ; return ( ( match ) \\/ ( len1 ) + ( match ) \\/ ( len2 ) + ( match - t ) \\/ ( match ) ) \\/ 3.0 ; } function jaro_Winkler ( s1 , s2 ) { let jaro_dist = jaro_distance ( s1 , s2 ) ; if ( jaro_dist > 0.7 ) { let prefix = 0 ; for ( let i = 0 ; i < Math . min ( s1 . length , s2 . length ) ; i ++ ) { if ( s1 [ i ] == s2 [ i ] ) prefix ++ ; else break ; } prefix = Math . min ( 4 , prefix ) ; jaro_dist += 0.1 * prefix * ( 1 - jaro_dist ) ; } return jaro_dist . toFixed ( 6 ) ; } let s1 = \\\" \\\" , s2 = \\\" \\\" ; document . write ( \\\" \\\" + jaro_Winkler ( s1 , s2 ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Program to find the Excenters of a Triangle | C ++ program for the above approach ; Function to calculate the distance between a pair of points ; Function to calculate the coordinates of the excenters of a triangle ; Length of the sides of the triangle ; Stores the coordinates of the excenters of the triangle ; For I1 ; For I2 ; For I3 ; Print the excenters of the triangle ; Driver Code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; float distance ( int m , int n , int p , int q ) { return sqrt ( pow ( n - m , 2 ) + pow ( q - p , 2 ) * 1.0 ) ; } void Excenters ( int x1 , int y1 , int x2 , int y2 , int x3 , int y3 ) { float a = distance ( x2 , x3 , y2 , y3 ) ; float b = distance ( x3 , x1 , y3 , y1 ) ; float c = distance ( x1 , x2 , y1 , y2 ) ; vector < pair < float , float > > excenter ( 4 ) ; excenter [ 1 ] . first = ( - ( a * x1 ) + ( b * x2 ) + ( c * x3 ) ) \\/ ( - a + b + c ) ; excenter [ 1 ] . second = ( - ( a * y1 ) + ( b * y2 ) + ( c * y3 ) ) \\/ ( - a + b + c ) ; excenter [ 2 ] . first = ( ( a * x1 ) - ( b * x2 ) + ( c * x3 ) ) \\/ ( a - b + c ) ; excenter [ 2 ] . second = ( ( a * y1 ) - ( b * y2 ) + ( c * y3 ) ) \\/ ( a - b + c ) ; excenter [ 3 ] . first = ( ( a * x1 ) + ( b * x2 ) - ( c * x3 ) ) \\/ ( a + b - c ) ; excenter [ 3 ] . second = ( ( a * y1 ) + ( b * y2 ) - ( c * y3 ) ) \\/ ( a + b - c ) ; for ( int i = 1 ; i <= 3 ; i ++ ) { cout << excenter [ i ] . first << \\\" ▁ \\\" << excenter [ i ] . second << endl ; } } int main ( ) { float x1 , x2 , x3 , y1 , y2 , y3 ; x1 = 0 ; x2 = 3 ; x3 = 0 ; y1 = 0 ; y2 = 0 ; y3 = 4 ; Excenters ( x1 , y1 , x2 , y2 , x3 , y3 ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Dynamic Programming | Returns true if there is a subset of set [ ] with sun equal to given sum ; The value of subset [ i ] [ j ] will be true if there is a subset of set [ 0. . j - 1 ] with sum equal to i ; If sum is 0 , then answer is true ; If sum is not 0 and set is empty , then answer is false ; Fill the subset table in botton up manner ; print table ; Driver Code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function isSubsetSum ( set , n , sum ) { let subset = new Array ( sum + 1 ) ; for ( let i = 0 ; i < sum + 1 ; i ++ ) { subset [ i ] = new Array ( sum + 1 ) ; for ( let j = 0 ; j < n + 1 ; j ++ ) { subset [ i ] [ j ] = 0 ; } } for ( let i = 0 ; i <= n ; i ++ ) subset [ 0 ] [ i ] = true ; for ( let i = 1 ; i <= sum ; i ++ ) subset [ i ] [ 0 ] = false ; for ( let i = 1 ; i <= sum ; i ++ ) { for ( let j = 1 ; j <= n ; j ++ ) { subset [ i ] [ j ] = subset [ i ] [ j - 1 ] ; if ( i >= set [ j - 1 ] ) subset [ i ] [ j ] = subset [ i ] [ j ] || subset [ i - set [ j - 1 ] ] [ j - 1 ] ; } } for ( int i = 0 ; i <= sum ; i ++ ) { for ( int j = 0 ; j <= n ; j ++ ) System . out . println ( subset [ i ] [ j ] ) ; } return subset [ sum ] [ n ] ; } let set = [ 3 , 34 , 4 , 12 , 5 , 2 ] ; let sum = 9 ; let n = set . length ; if ( isSubsetSum ( set , n , sum ) == true ) document . write ( \\\" \\\" + \\\" \\\" ) ; else document . write ( \\\" \\\" + \\\" \\\" ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Binomial Coefficient | DP | A Naive Recursive Implementation ; Returns value of Binomial Coefficient C ( n , k ) ; Base Cases ; Recur ; Driver program to test above function\\\"\\nSolution in C:\",\"targets\":\"#include \\nint binomialCoeff ( int n , int k ) { if ( k > n ) return 0 ; if ( k == 0 k == n ) return 1 ; return binomialCoeff ( n - 1 , k - 1 ) + binomialCoeff ( n - 1 , k ) ; } int main ( ) { int n = 5 , k = 2 ; printf ( \\\" Value ▁ of ▁ C ( % d , ▁ % d ) ▁ is ▁ % d ▁ \\\" , n , k , binomialCoeff ( n , k ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Program to find the sum of a Series 1 + 1 \\/ 2 ^ 2 + 1 \\/ 3 ^ 3 + â €¦ . . + 1 \\/ n ^ n | C program to calculate the following series ; Function to calculate the following series ; Driver Code\\\"\\nSolution in C:\",\"targets\":\"#include \\n#include \\ndouble Series ( int n ) { int i ; double sums = 0.0 , ser ; for ( i = 1 ; i <= n ; ++ i ) { ser = 1 \\/ pow ( i , i ) ; sums += ser ; } return sums ; } int main ( ) { int n = 3 ; double res = Series ( n ) ; printf ( \\\" % .5f \\\" , res ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Count even length subarrays having bitwise XOR equal to 0 | Java program to implement the above approach ; Function to get the count of even length subarrays having bitwise xor 0 ; Stores prefix - xor of the given array ; Stores prefix - xor at even index of the array . ; Stores prefix - xor at odd index of the array . ; Stores count of subarrays that satisfy the condition ; length from 0 index to odd index is even ; Traverse the array . ; Take prefix - xor ; If index is odd ; Calculate pairs ; Increment prefix - xor at odd index ; Calculate pairs ; Increment prefix - xor at odd index ; Driver Code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { static final int M = 1000000 ; static int cntSubXor ( int arr [ ] , int N ) { int prefixXor = 0 ; int [ ] Even = new int [ M ] ; int [ ] Odd = new int [ M ] ; int cntSub = 0 ; Odd [ 0 ] = 1 ; for ( int i = 0 ; i < N ; i ++ ) { prefixXor ^= arr [ i ] ; if ( i % 2 == 1 ) { cntSub += Odd [ prefixXor ] ; Odd [ prefixXor ] ++ ; } else { cntSub += Even [ prefixXor ] ; Even [ prefixXor ] ++ ; } } return cntSub ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 2 , 3 , 3 , 6 , 7 , 8 } ; int N = arr . length ; System . out . print ( cntSubXor ( arr , N ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Count of integral coordinates that lies inside a Square | Function to calculate the integral points inside a square ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"def countIntgralPoints ( x1 , y1 , x2 , y2 ) :\\n\\tprint ( ( y2 - y1 - 1 ) * ( x2 - x1 - 1 ) )\\nif __name__ == ' _ _ main _ _ ' :\\n\\tx1 = 1\\n\\ty1 = 1\\n\\tx2 = 4\\n\\ty2 = 4\\n\\tcountIntgralPoints ( x1 , y1 , x2 , y2 )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Tetranacci Numbers | Function to return the N - th tetranacci number ; base cases ; base cases ; base cases ; function to print the nth tetranacci number ; Driver code\\\"\\nSolution in php:\",\"targets\":\"< ? php function printTetraRec ( $ n ) { if ( $ n == 0 ) return 0 ; if ( $ n == 1 $ n == 2 ) return 1 ; if ( $ n == 3 ) return 2 ; else return printTetraRec ( $ n - 1 ) + printTetraRec ( $ n - 2 ) + printTetraRec ( $ n - 3 ) + printTetraRec ( $ n - 4 ) ; } function printTetra ( $ n ) { echo printTetraRec ( $ n ) . \\\" \\\" ; } $ n = 10 ; printTetra ( $ n ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Sum of elements in an array having composite frequency | C ++ program to find sum of elements in an array having composite frequency ; Function to create Sieve to check primes ; If composite [ p ] is not changed , then it is a prime ; Update all multiples of p , set them to composite ; Function to return the sum of elements in an array having composite frequency ; Map is used to store element frequencies ; To store sum ; Traverse the map using iterators ; Count the number of elements having composite frequencies ; Driver code ; Function call\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; #define N 100005\\nvoid SieveOfEratosthenes ( vector < bool > & composite ) { for ( int i = 0 ; i < N ; i ++ ) composite [ i ] = false ; for ( int p = 2 ; p * p < N ; p ++ ) { if ( ! composite [ p ] ) { for ( int i = p * 2 ; i < N ; i += p ) composite [ i ] = true ; } } } int sumOfElements ( int arr [ ] , int n ) { vector < bool > composite ( N ) ; SieveOfEratosthenes ( composite ) ; unordered_map < int , int > m ; for ( int i = 0 ; i < n ; i ++ ) m [ arr [ i ] ] ++ ; int sum = 0 ; for ( auto it = m . begin ( ) ; it != m . end ( ) ; it ++ ) { if ( composite [ it -> second ] ) { sum += ( it -> first ) ; } } return sum ; } int main ( ) { int arr [ ] = { 1 , 2 , 1 , 1 , 1 , 3 , 3 , 2 , 4 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; cout << sumOfElements ( arr , n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Modify array such that the array does not contain any common divisors other than 1 | Java program for the above approach ; Function to check if it is possible to modify the array such that there is no common factor between array elements except 1 ; Stores GCD of the array ; Calculate GCD of the array ; If the current divisor is smaller than X ; Divide GCD by the current divisor ; If possible ; Print the modified array ; Otherwise ; Calculating gcd ; Driver Code ; Given array ; Size of the array\\\"\\nSolution in Java:\",\"targets\":\"class GFG { static void checkCommonDivisor ( int [ ] arr , int N , int X ) { int G = 0 ; for ( int i = 0 ; i < N ; i ++ ) { G = gcd ( G , arr [ i ] ) ; } int copy_G = G ; for ( int divisor = 2 ; divisor <= X ; divisor ++ ) { while ( G % divisor == 0 ) { G = G \\/ divisor ; } } if ( G <= X ) { System . out . println ( \\\" Yes \\\" ) ; for ( int i = 0 ; i < N ; i ++ ) System . out . print ( ( arr [ i ] \\/ copy_G ) + \\\" ▁ \\\" ) ; System . out . println ( ) ; } else System . out . println ( \\\" No \\\" ) ; } static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 6 , 15 , 6 } ; int X = 6 ; int N = arr . length ; checkCommonDivisor ( arr , N , X ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"String containing first letter of every word in a given string with spaces | C ++ program to find the string which contain the first character of each word of another string . ; Function to find string which has first character of each word . ; Traverse the string . ; If it is space , set v as true . ; Else check if v is true or not . If true , copy character in output string and set v as false . ; Driver cpde\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; string firstLetterWord ( string str ) { string result = \\\" \\\" ; bool v = true ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str [ i ] == ' ▁ ' ) v = true ; else if ( str [ i ] != ' ▁ ' && v == true ) { result . push_back ( str [ i ] ) ; v = false ; } } return result ; } int main ( ) { string str = \\\" geeks ▁ for ▁ geeks \\\" ; cout << firstLetterWord ( str ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Check whether a given point lies on or inside the rectangle | Set 3 | function to Check whether a given point lies inside or on the rectangle or not ; Driver code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def LiesInsieRectangle ( a , b , x , y ) :\\n\\tif ( x - y - b <= 0 and x - y + b >= 0 and x + y - 2 * a + b <= 0 and x + y - b >= 0 ) :\\n\\t\\treturn True\\n\\treturn False\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\ta , b , x , y = 7 , 2 , 4 , 5\\n\\tif LiesInsieRectangle ( a , b , x , y ) :\\n\\t\\tprint ( \\\" Given ▁ point ▁ lies ▁ inside \\\" \\\" ▁ the ▁ rectangle \\\" )\\n\\telse :\\n\\t\\tprint ( \\\" Given ▁ point ▁ does ▁ not ▁ lie \\\" \\\" ▁ on ▁ the ▁ rectangle \\\" )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"All about Bit Manipulation | Function to clear the ith bit of the given number N ; Create the mask for the ith bit unset ; Return the update value\\\"\\nSolution in C#:\",\"targets\":\"static int clearBit ( int num , int i ) { int mask = ~ ( 1 << i ) ; return num & mask ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Minimum steps to reach the Nth stair in jumps of perfect power of 2 | Function to count the number of jumps required to reach Nth stairs . ; Till N becomes 0 ; Removes the set bits from the right to left ; Number of stairs ; Function Call\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function stepRequired ( N ) { let cnt = 0 ; while ( N ) { N = N & ( N - 1 ) ; cnt ++ ; } return cnt ; } let N = 23 ; document . write ( stepRequired ( N ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Check if sum of digits of a number exceeds the product of digits of that number | Function to check if the sum of the digits of N is strictly greater than the product of the digits of N or not ; Stores the sum and the product of the digits of N ; Stores the last digit if N ; Increment the value of sumOfDigits ; Update the prodOfDigit ; Divide N by 10 ; Print the result ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"def check ( n ) :\\n\\tsumOfDigit = 0\\n\\tprodOfDigit = 1\\n\\twhile n > 0 :\\n\\t\\trem = n % 10\\n\\t\\tsumOfDigit += rem\\n\\t\\tprodOfDigit *= rem\\n\\t\\tn = n \\/\\/ 10\\n\\tif sumOfDigit > prodOfDigit :\\n\\t\\tprint ( \\\" Yes \\\" )\\n\\telse :\\n\\t\\tprint ( \\\" No \\\" )\\nN = 1234\\ncheck ( N )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"Ternary Search | C program to illustrate iterative approach to ternary search ; Function to perform Ternary Search ; Find the mid1 and mid2 ; Check if key is present at any mid ; Since key is not present at mid , check in which region it is present then repeat the Search operation in that region ; The key lies in between l and mid1 ; The key lies in between mid2 and r ; The key lies in between mid1 and mid2 ; Key not found ; Driver code ; Get the array Sort the array if not sorted ; Starting index ; length of array ; Key to be searched in the array ; Search the key using ternarySearch ; Print the result ; Key to be searched in the array ; Search the key using ternarySearch ; Print the result\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint ternarySearch ( int l , int r , int key , int ar [ ] ) { while ( r >= l ) { int mid1 = l + ( r - l ) \\/ 3 ; int mid2 = r - ( r - l ) \\/ 3 ; if ( ar [ mid1 ] == key ) { return mid1 ; } if ( ar [ mid2 ] == key ) { return mid2 ; } if ( key < ar [ mid1 ] ) { r = mid1 - 1 ; } else if ( key > ar [ mid2 ] ) { l = mid2 + 1 ; } else { l = mid1 + 1 ; r = mid2 - 1 ; } } return -1 ; } int main ( ) { int l , r , p , key ; int ar [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 } ; l = 0 ; r = 9 ; key = 5 ; p = ternarySearch ( l , r , key , ar ) ; printf ( \\\" Index ▁ of ▁ % d ▁ is ▁ % d \\n \\\" , key , p ) ; key = 50 ; p = ternarySearch ( l , r , key , ar ) ; printf ( \\\" Index ▁ of ▁ % d ▁ is ▁ % d \\\" , key , p ) ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Count quadruples of given type from given array | Python3 program of the above approach ; lcount [ i ] [ j ] : Stores the count of i on left of index j ; rcount [ i ] [ j ] : Stores the count of i on right of index j ; Function to count unique elements on left and right of any index ; Find the maximum array element ; Calculate prefix sum of counts of each value ; Calculate suffix sum of counts of each value ; Function to count quadruples of the required type ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"maxN = 2002\\nlcount = [ [ 0 for i in range ( maxN ) ] for j in range ( maxN ) ]\\nrcount = [ [ 0 for i in range ( maxN ) ] for j in range ( maxN ) ]\\ndef fill_counts ( a , n ) :\\n\\tmaxA = a [ 0 ]\\n\\tfor i in range ( n ) :\\n\\t\\tif ( a [ i ] > maxA ) :\\n\\t\\t\\tmaxA = a [ i ]\\n\\tfor i in range ( n ) :\\n\\t\\tlcount [ a [ i ] ] [ i ] = 1\\n\\t\\trcount [ a [ i ] ] [ i ] = 1\\n\\tfor i in range ( maxA + 1 ) :\\n\\t\\tfor j in range ( n ) :\\n\\t\\t\\tlcount [ i ] [ j ] = ( lcount [ i ] [ j - 1 ] + lcount [ i ] [ j ] )\\n\\t\\tfor j in range ( n - 2 , - 1 , - 1 ) :\\n\\t\\t\\trcount [ i ] [ j ] = ( rcount [ i ] [ j + 1 ] + rcount [ i ] [ j ] )\\ndef countSubsequence ( a , n ) :\\n\\tfill_counts ( a , n )\\n\\tanswer = 0\\n\\tfor i in range ( 1 , n ) :\\n\\t\\tfor j in range ( i + 1 , n - 1 ) :\\n\\t\\t\\tanswer += ( lcount [ a [ j ] ] [ i - 1 ] * rcount [ a [ i ] ] [ j + 1 ] )\\n\\treturn answer\\na = [ 1 , 2 , 3 , 2 , 1 , 3 , 2 ]\\nprint ( countSubsequence ( a , 7 ) )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Find the sum of first N odd Fibonacci numbers | Python3 program to Find the sum of first N odd Fibonacci numbers ; Function to calculate sum of first N odd Fibonacci numbers ; base values ; Driver code\\\"\\nSolution in Python:\",\"targets\":\"mod = 1000000007 ;\\ndef sumOddFibonacci ( n ) :\\n\\tSum = [ 0 ] * ( n + 1 ) ;\\n\\tSum [ 0 ] = 0 ;\\n\\tSum [ 1 ] = 1 ;\\n\\tSum [ 2 ] = 2 ;\\n\\tSum [ 3 ] = 5 ;\\n\\tSum [ 4 ] = 10 ;\\n\\tSum [ 5 ] = 23 ;\\n\\tfor i in range ( 6 , n + 1 ) :\\n\\t\\tSum [ i ] = ( ( Sum [ i - 1 ] + ( 4 * Sum [ i - 2 ] ) % mod - ( 4 * Sum [ i - 3 ] ) % mod + mod ) % mod + ( Sum [ i - 4 ] - Sum [ i - 5 ] + mod ) % mod ) % mod ;\\n\\treturn Sum [ n ] ;\\nn = 6 ;\\nprint ( sumOddFibonacci ( n ) ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Program to find the N | C # program to find n - th number containing only 3 and 5. ; If n is odd , append 3 and move to parent ; If n is even , append 5 and move to parent ; Reverse res and return . ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { if ( ( n & 1 ) == 1 ) { res = res + \\\" 3 \\\" ; n = ( n - 1 ) \\/ 2 ; } else { res = res + \\\" 5 \\\" ; n = ( n - 2 ) \\/ 2 ; } } string sb = Reverse ( res ) ; return sb ; } static void Main ( ) { int n = 5 ; Console . WriteLine ( findNthNo ( n ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Program to find whether a given number is power of 2 | Function to check if x is power of 2 ; First x in the below expression is for the case when x is 0 ; Driver code\\\"\\nSolution in Python:\",\"targets\":\"def isPowerOfTwo ( x ) :\\n\\treturn ( x and ( not ( x & ( x - 1 ) ) ) )\\nif ( isPowerOfTwo ( 31 ) ) :\\n\\tprint ( ' Yes ' )\\nelse :\\n\\tprint ( ' No ' )\\nif ( isPowerOfTwo ( 64 ) ) :\\n\\tprint ( ' Yes ' )\\nelse :\\n\\tprint ( ' No ' )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Find all Pairs possible from the given Array | Function to print all possible pairs from the array ; Nested loop for all possible pairs ; Driver code\\\"\\nSolution in Javascript:\",\"targets\":\"function printPairs ( arr , n ) { for ( var i = 0 ; i < n ; i ++ ) { for ( var j = 0 ; j < n ; j ++ ) { document . write ( \\\" \\\" + arr [ i ] + \\\" \\\" + arr [ j ] + \\\" \\\" + \\\" \\\" ) ; } } } var arr = [ 1 , 2 ] ; var n = arr . length ; printPairs ( arr , n ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Find the minimum element in a sorted and rotated array | PHP program to find minimum element in a sorted and rotated array ; This condition is needed to handle the case when array is not rotated at all ; If there is only one element left ; Find mid ; Check if element ( mid + 1 ) is minimum element . Consider the cases like ( 3 , 4 , 5 , 1 , 2 ) ; Check if mid itself is minimum element ; Decide whether we need to go to left half or right half ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function findMin ( $ arr , $ low , $ high ) { if ( $ high < $ low ) return $ arr [ 0 ] ; if ( $ high == $ low ) return $ arr [ $ low ] ; $ mid = $ low + ( $ high - $ low ) \\/ 2 ; if ( $ mid < $ high && $ arr [ $ mid + 1 ] < $ arr [ $ mid ] ) return $ arr [ $ mid + 1 ] ; if ( $ mid > $ low && $ arr [ $ mid ] < $ arr [ $ mid - 1 ] ) return $ arr [ $ mid ] ; if ( $ arr [ $ high ] > $ arr [ $ mid ] ) return findMin ( $ arr , $ low , $ mid - 1 ) ; return findMin ( $ arr , $ mid + 1 , $ high ) ; } $ arr1 = array ( 5 , 6 , 1 , 2 , 3 , 4 ) ; $ n1 = sizeof ( $ arr1 ) ; echo \\\" The ▁ minimum ▁ element ▁ is ▁ \\\" . findMin ( $ arr1 , 0 , $ n1 - 1 ) . \\\" \\n \\\" ; $ arr2 = array ( 1 , 2 , 3 , 4 ) ; $ n2 = sizeof ( $ arr2 ) ; echo \\\" The ▁ minimum ▁ element ▁ is ▁ \\\" . findMin ( $ arr2 , 0 , $ n2 - 1 ) . \\\" \\n \\\" ; $ arr3 = array ( 1 ) ; $ n3 = sizeof ( $ arr3 ) ; echo \\\" The ▁ minimum ▁ element ▁ is ▁ \\\" . findMin ( $ arr3 , 0 , $ n3 - 1 ) . \\\" \\n \\\" ; $ arr4 = array ( 1 , 2 ) ; $ n4 = sizeof ( $ arr4 ) ; echo \\\" The ▁ minimum ▁ element ▁ is ▁ \\\" . findMin ( $ arr4 , 0 , $ n4 - 1 ) . \\\" \\n \\\" ; $ arr5 = array ( 2 , 1 ) ; $ n5 = sizeof ( $ arr5 ) ; echo \\\" The ▁ minimum ▁ element ▁ is ▁ \\\" . findMin ( $ arr5 , 0 , $ n5 - 1 ) . \\\" \\n \\\" ; $ arr6 = array ( 5 , 6 , 7 , 1 , 2 , 3 , 4 ) ; $ n6 = sizeof ( $ arr6 ) ; echo \\\" The ▁ minimum ▁ element ▁ is ▁ \\\" . findMin ( $ arr6 , 0 , $ n6 - 1 ) . \\\" \\n \\\" ; $ arr7 = array ( 1 , 2 , 3 , 4 , 5 , 6 , 7 ) ; $ n7 = sizeof ( $ arr7 ) ; echo \\\" The ▁ minimum ▁ element ▁ is ▁ \\\" . findMin ( $ arr7 , 0 , $ n7 - 1 ) . \\\" \\n \\\" ; $ arr8 = array ( 2 , 3 , 4 , 5 , 6 , 7 , 8 , 1 ) ; $ n8 = sizeof ( $ arr8 ) ; echo \\\" The ▁ minimum ▁ element ▁ is ▁ \\\" . findMin ( $ arr8 , 0 , $ n8 - 1 ) . \\\" \\n \\\" ; $ arr9 = array ( 3 , 4 , 5 , 1 , 2 ) ; $ n9 = sizeof ( $ arr9 ) ; echo \\\" The ▁ minimum ▁ element ▁ is ▁ \\\" . findMin ( $ arr9 , 0 , $ n9 - 1 ) . \\\" \\n \\\" ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Taxicab Numbers | PHP implementation to print first N Taxicab ( 2 ) numbers : ; Starting from 1 , check every number if it is Taxicab until count reaches N . ; Try all possible pairs ( j , k ) whose cube sums can be i . ; Taxicab ( 2 ) found ; Driver code\\\"\\nSolution in php:\",\"targets\":\"< ? php function printTaxicab2 ( $ N ) { $ i = 1 ; $ count = 0 ; while ( $ count < $ N ) { $ int_count = 0 ; for ( $ j = 1 ; $ j <= pow ( $ i , 1.0 \\/ 3 ) ; $ j ++ ) for ( $ k = $ j + 1 ; $ k <= pow ( $ i , 1.0 \\/ 3 ) ; $ k ++ ) if ( $ j * $ j * $ j + $ k * $ k * $ k == $ i ) $ int_count ++ ; if ( $ int_count == 2 ) { $ count ++ ; echo $ count , \\\" \\\" , ▁ $ i , ▁ \\\" \\\" } $ i ++ ; } } $ N = 5 ; printTaxicab2 ( $ N ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Maximize the first element of the array such that average remains constant | Java implementation of to maximize the first element of the array such that average of the array remains constant ; Maximum value of the first array element that can be attained ; Variable to store the sum ; Loop to find the sum of array ; Desired maximum value ; Driver Code\\\"\\nSolution in Java:\",\"targets\":\"import java . util . * ; class GFG { static void getmax ( int arr [ ] , int n , int x ) { int s = 0 ; for ( int i = 0 ; i < n ; i ++ ) { s = s + arr [ i ] ; } System . out . print ( Math . min ( s , x ) ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int x = 5 ; int arr_size = arr . length ; getmax ( arr , arr_size , x ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Check if it is possible to rearrange a binary string with alternate 0 s and 1 s | CPP program to check if we can rearrange a string such that it has alternate 0 s and 1 s . ; function to check the binary string ; length of string ; count zero 's ; count one 's ; if length is even ; if length is odd ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; bool is_possible ( string s ) { int l = s . length ( ) ; int one = 0 , zero = 0 ; for ( int i = 0 ; i < l ; i ++ ) { if ( s [ i ] == '0' ) zero ++ ; else one ++ ; } if ( l % 2 == 0 ) return ( one == zero ) ; else return ( abs ( one - zero ) == 1 ) ; } int main ( ) { string s = \\\"100110\\\" ; if ( is_possible ( s ) ) cout << \\\" Yes \\\" ; else cout << \\\" No \\\" ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Count of contiguous subarrays possible for every index by including the element at that index | C # program to find the number of contiguous subarrays including the element at every index of the array of size N ; Function to find the number of subarrays including the element at every index of the array ; Creating an array of size N ; The loop is iterated till half the length of the array ; Condition to avoid overwriting the middle element for the array with even length . ; Computing the number of subarrays ; The ith element from the beginning and the ending have the same number of possible subarray ; Function to print the vector ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { public static int [ ] calculateWays ( int N ) { int x = 0 ; int [ ] v = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) v [ i ] = 0 ; for ( int i = 0 ; i < N \\/ 2 ; i ++ ) { if ( N % 2 == 0 && i == N \\/ 2 ) break ; x = N * ( i + 1 ) - ( i + 1 ) * i ; v [ i ] = x ; v [ N - i - 1 ] = x ; } return v ; } public static void printArray ( int [ ] v ) { for ( int i = 0 ; i < v . Length ; i ++ ) { Console . Write ( v [ i ] + \\\" ▁ \\\" ) ; } } public static void Main ( string [ ] args ) { int [ ] v ; v = calculateWays ( 4 ) ; printArray ( v ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"Squareroot ( n ) | C program to find sqrt ( n ) 'th node of a linked list ; Linked list node ; Function to get the sqrt ( n ) th node of a linked list ; Traverse the list ; check if j = sqrt ( i ) ; for first node ; increment j if j = sqrt ( i ) ; return node 's data ; function to add a new node at the beginning of the list ; allocate node ; put in the data ; link the old list off the new node ; move the head to point to the new node ; Driver program to test above function ; Start with the empty list\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#include \\nstruct Node { int data ; struct Node * next ; } ; int printsqrtn ( struct Node * head ) { struct Node * sqrtn = NULL ; int i = 1 , j = 1 ; while ( head != NULL ) { if ( i == j * j ) { if ( sqrtn == NULL ) sqrtn = head ; else sqrtn = sqrtn -> next ; j ++ ; } i ++ ; head = head -> next ; } return sqrtn -> data ; } void print ( struct Node * head ) { while ( head != NULL ) { printf ( \\\" % d ▁ \\\" , head -> data ) ; head = head -> next ; } printf ( \\\" \\n \\\" ) ; } void push ( struct Node * * head_ref , int new_data ) { struct Node * new_node = ( struct Node * ) malloc ( sizeof ( struct Node ) ) ; new_node -> data = new_data ; new_node -> next = ( * head_ref ) ; ( * head_ref ) = new_node ; } int main ( ) { struct Node * head = NULL ; push ( & head , 40 ) ; push ( & head , 30 ) ; push ( & head , 20 ) ; push ( & head , 10 ) ; printf ( \\\" Given ▁ linked ▁ list ▁ is : \\\" ) ; print ( head ) ; printf ( \\\" sqrt ( n ) th ▁ node ▁ is ▁ % d ▁ \\\" , printsqrtn ( head ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Minimize cost to replace all the vowels of a given String by a single vowel | Function that return true if the given character is a vowel ; Function to return the minimum cost to convert all the vowels of a string to a single one ; St || es count of respective vowels ; Iterate through the string ; If a vowel is encountered ; Calculate the cost ; Return the Math . minimum cost ; Driver Code\\\"\\nSolution in Javascript:\",\"targets\":\"function isVowel ( ch ) { if ( ch == ' ' ch == ' ' ch == ' ' ch == ' ' ch == ' ' ) return true ; else return false ; } function minCost ( S ) { var cA = 0 ; var cE = 0 ; var cI = 0 ; var cO = 0 ; var cU = 0 ; for ( var i = 0 ; i < S . length ; i ++ ) { if ( isVowel ( S [ i ] ) ) { cA += Math . abs ( S . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) ) ; cE += Math . abs ( S . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) ) ; cI += Math . abs ( S . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) ) ; cO += Math . abs ( S . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) ) ; cU += Math . abs ( S . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) ) ; } } return Math . min ( Math . min ( Math . min ( Math . min ( cA , cE ) , cI ) , cO ) , cU ) ; } var S = \\\" \\\" ; document . write ( minCost ( S ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Compute modulus division by a power | This function will return n % d . d must be one of : 1 , 2 , 4 , 8 , 16 , 32 , ... ; Driver Code ; d must be a power of 2\\\"\\nSolution in php:\",\"targets\":\"< ? php function getModulo ( $ n , $ d ) { return ( $ n & ( $ d - 1 ) ) ; } $ n = 6 ; $ d = 4 ; echo $ n , \\\" ▁ moduo \\\" , \\\" ▁ \\\" , $ d , \\\" ▁ is ▁ \\\" , \\\" ▁ \\\" , getModulo ( $ n , $ d ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Minimize the maximum difference of adjacent elements after at most K insertions | C # program to find the minimum of maximum difference between adjacent elements after at most K insertions ; Calculate the maximum adjacent difference ; If the maximum adjacent difference is already zero ; best and worst specifies range of the maximum adjacent difference ; To store the no of insertions required for respective values of mid ; If the number of insertions required exceeds K ; Otherwise ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int minMaxDiff ( int [ ] arr , int n , int k ) { int max_adj_dif = int . MinValue ; for ( int i = 0 ; i < n - 1 ; i ++ ) max_adj_dif = Math . Max ( max_adj_dif , Math . Abs ( arr [ i ] - arr [ i + 1 ] ) ) ; if ( max_adj_dif == 0 ) return 0 ; int best = 1 ; int worst = max_adj_dif ; int mid , required ; while ( best < worst ) { mid = ( best + worst ) \\/ 2 ; required = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { required += ( Math . Abs ( arr [ i ] - arr [ i + 1 ] ) - 1 ) \\/ mid ; } if ( required > k ) best = mid + 1 ; else worst = mid ; } return worst ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 12 , 25 , 50 } ; int n = arr . Length ; int k = 7 ; Console . WriteLine ( minMaxDiff ( arr , n , k ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Program for factorial of a number | C # program to find factorial of the given number ; single line to find factorial ; Driver Code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class Factorial { int factorial ( int n ) { return ( n == 1 n == 0 ) ? 1 : n * factorial ( n - 1 ) ; } public static void Main ( ) { Factorial obj = new Factorial ( ) ; int num = 5 ; Console . WriteLine ( \\\" Factorial ▁ of ▁ \\\" + num + \\\" ▁ is ▁ \\\" + obj . factorial ( num ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Program to find the Encrypted word | C # program to implement the above approach ; Static function declared to find the encrypted string ; Character array to store the encrypted string ; after ' z ' , it should go to a . ; storing the character array in the string . ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { public static void findWord ( String c , int n ) { int co = 0 , i ; char [ ] s = new char [ n ] ; for ( i = 0 ; i < n ; i ++ ) { if ( i < n \\/ 2 ) co ++ ; else co = n - i ; if ( ( c [ i ] + co ) <= 122 ) s [ i ] = ( char ) ( ( int ) c [ i ] + co ) ; else s [ i ] = ( char ) ( ( int ) c [ i ] + co - 26 ) ; } String str = String . Join ( \\\" \\\" , s ) ; Console . WriteLine ( str ) ; } public static void Main ( String [ ] args ) { String s = \\\" abcd \\\" ; findWord ( s , s . Length ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Counting numbers of n digits that are monotone | Considering all possible digits as { 1 , 2 , 3 , . .9 } ; DP [ i ] [ j ] is going to store monotone numbers of length i + 1 considering j + 1 digits . ; Unit length numbers ; Single digit numbers ; Filling rest of the entries in bottom up manner . ; Driver code\\\"\\nSolution in Python:\",\"targets\":\"DP_s = 9\\ndef getNumMonotone ( ln ) :\\n\\tDP = [ [ 0 ] * DP_s for i in range ( ln ) ]\\n\\tfor i in range ( DP_s ) :\\n\\t\\tDP [ 0 ] [ i ] = i + 1\\n\\tfor i in range ( ln ) :\\n\\t\\tDP [ i ] [ 0 ] = 1\\n\\tfor i in range ( 1 , ln ) :\\n\\t\\tfor j in range ( 1 , DP_s ) :\\n\\t\\t\\tDP [ i ] [ j ] = DP [ i - 1 ] [ j ] + DP [ i ] [ j - 1 ]\\n\\treturn DP [ ln - 1 ] [ DP_s - 1 ]\\nprint ( getNumMonotone ( 10 ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Check if a number can be expressed as a ^ b | Set 2 | PHP program to check if a number can be expressed as a ^ b . ; Driver code\\\"\\nSolution in php:\",\"targets\":\"< ? php function isPower ( $ a ) { if ( $ a == 1 ) return true ; for ( $ i = 2 ; $ i * $ i <= $ a ; $ i ++ ) { $ val = log ( $ a ) \\/ log ( $ i ) ; if ( ( $ val - $ val ) < 0.00000001 ) return true ; } return false ; } $ n = 16 ; echo ( isPower ( $ n ) ? \\\" Yes \\\" : \\\" No \\\" ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Sum of all differences between Maximum and Minimum of increasing Subarrays | C # program to find the sum of differences of maximum and minimum of strictly increasing subarrays ; Function to calculate and return the sum of differences of maximum and minimum of strictly increasing subarrays ; Stores the sum ; Traverse the array ; If last element of the increasing sub - array is found ; Update sum ; If the last element of the array is reached ; Update sum ; Return the sum ; Driver Code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static int sum_of_differences ( int [ ] arr , int N ) { int sum = 0 ; int i , j , flag ; for ( i = 0 ; i < N - 1 ; i ++ ) { if ( arr [ i ] < arr [ i + 1 ] ) { flag = 0 ; for ( j = i + 1 ; j < N - 1 ; j ++ ) { if ( arr [ j ] >= arr [ j + 1 ] ) { sum += ( arr [ j ] - arr [ i ] ) ; i = j ; flag = 1 ; break ; } } if ( flag == 0 && arr [ i ] < arr [ N - 1 ] ) { sum += ( arr [ N - 1 ] - arr [ i ] ) ; break ; } } } return sum ; } public static void Main ( string [ ] args ) { int [ ] arr = { 6 , 1 , 2 , 5 , 3 , 4 } ; int N = arr . Length ; Console . Write ( sum_of_differences ( arr , N ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Program to find the largest and smallest ASCII valued characters in a string | C # program to find largest and smallest characters in a string . ; function that return the largest alphabet . ; initializing max alphabet to ' a ' ; find largest alphabet ; returning largest element ; function that return the smallest alphabet ; initializing smallest alphabet to ' z ' ; find smallest alphabet ; returning smallest alphabet ; Driver Code ; Input String ; Calculating size of the string ; calling functions and print returned value\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static char largest_alphabet ( String a , int n ) { char max = ' A ' ; for ( int i = 0 ; i < n ; i ++ ) if ( a [ i ] > max ) max = a [ i ] ; return max ; } static char smallest_alphabet ( String a , int n ) { char min = ' z ' ; for ( int i = 0 ; i < n - 1 ; i ++ ) if ( a [ i ] < min ) min = a [ i ] ; return min ; } public static void Main ( ) { String a = \\\" GeEksforGeeks \\\" ; int size = a . Length ; Console . Write ( \\\" Largest ▁ and ▁ smallest ▁ alphabet ▁ is ▁ : ▁ \\\" ) ; Console . Write ( largest_alphabet ( a , size ) + \\\" ▁ and ▁ \\\" ) ; Console . Write ( smallest_alphabet ( a , size ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"Print cousins of a given node in Binary Tree | C program to print cousins of a node ; A Binary Tree Node ; A utility function to create a new Binary Tree Node ; It returns level of the node if it is present in tree , otherwise returns 0. ; base cases ; If node is present in left subtree ; If node is not present in left subtree ; Print nodes at a given level such that sibling of node is not printed if it exists ; Base cases ; If current node is parent of a node with given level ; Recur for left and right subtrees ; This function prints cousins of a given node ; Get level of given node ; Print nodes of given level . ; Driver Program to test above functions\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#include \\nstruct Node { int data ; Node * left , * right ; } ; Node * newNode ( int item ) { Node * temp = new Node ; temp -> data = item ; temp -> left = temp -> right = NULL ; return temp ; } int getLevel ( Node * root , Node * node , int level ) { if ( root == NULL ) return 0 ; if ( root == node ) return level ; int downlevel = getLevel ( root -> left , node , level + 1 ) ; if ( downlevel != 0 ) return downlevel ; return getLevel ( root -> right , node , level + 1 ) ; } void printGivenLevel ( Node * root , Node * node , int level ) { if ( root == NULL level < 2 ) return ; if ( level == 2 ) { if ( root -> left == node root -> right == node ) return ; if ( root -> left ) printf ( \\\" % d ▁ \\\" , root -> left -> data ) ; if ( root -> right ) printf ( \\\" % d ▁ \\\" , root -> right -> data ) ; } else if ( level > 2 ) { printGivenLevel ( root -> left , node , level - 1 ) ; printGivenLevel ( root -> right , node , level - 1 ) ; } } void printCousins ( Node * root , Node * node ) { int level = getLevel ( root , node , 1 ) ; printGivenLevel ( root , node , level ) ; } int main ( ) { Node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> left -> left = newNode ( 4 ) ; root -> left -> right = newNode ( 5 ) ; root -> left -> right -> right = newNode ( 15 ) ; root -> right -> left = newNode ( 6 ) ; root -> right -> right = newNode ( 7 ) ; root -> right -> left -> right = newNode ( 8 ) ; printCousins ( root , root -> left -> right ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Minimum size of set having either element in range [ 0 , X ] or an odd power of 2 with sum N | Function to find the highest odd power of 2 in the range [ 0 , N ] ; If P is even , subtract 1 ; Function to find the minimum operations to make N ; If N is odd and X = 0 , then no valid set exist ; Stores the minimum possible size of the valid set ; Loop to subtract highest odd power of 2 while X < N , step 2 ; If N > 0 , then increment the value of answer by 1 ; Return the resultant size of set ; Driver Code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function highestPowerof2 ( n ) { let p = Math . floor ( Math . log2 ( n ) ) ; if ( p % 2 == 0 ) { p -= 1 } return Math . pow ( 2 , p ) } function minStep ( N , X ) { if ( N % 2 != 0 && X == 0 ) return - 1 let size = 0 while ( X < N ) { N -= highestPowerof2 ( N ) size += 1 } if ( N != 0 ) size += 1 return size ; } let N = 11 let X = 2 document . write ( minStep ( N , X ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Matrix Chain Multiplication | DP | See the Cormen book for details of the following algorithm ; Matrix Ai has dimension p [ i - 1 ] x p [ i ] for i = 1. . n ; For simplicity of the program , one extra row and one extra column are allocated in m [ ] [ ] . 0 th row and 0 th column of m [ ] [ ] are not used ; cost is zero when multiplying one matrix . ; L is chain length . ; q = cost \\/ scalar multiplications ; Driver code\\\"\\nSolution in C:\",\"targets\":\"#include \\n#include \\nint MatrixChainOrder ( int p [ ] , int n ) { int m [ n ] [ n ] ; int i , j , k , L , q ; for ( i = 1 ; i < n ; i ++ ) m [ i ] [ i ] = 0 ; for ( L = 2 ; L < n ; L ++ ) { for ( i = 1 ; i < n - L + 1 ; i ++ ) { j = i + L - 1 ; m [ i ] [ j ] = INT_MAX ; for ( k = i ; k <= j - 1 ; k ++ ) { q = m [ i ] [ k ] + m [ k + 1 ] [ j ] + p [ i - 1 ] * p [ k ] * p [ j ] ; if ( q < m [ i ] [ j ] ) m [ i ] [ j ] = q ; } } } return m [ 1 ] [ n - 1 ] ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int size = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; printf ( \\\" Minimum ▁ number ▁ of ▁ multiplications ▁ is ▁ % d ▁ \\\" , MatrixChainOrder ( arr , size ) ) ; getchar ( ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Number of digits in the product of two numbers | C ++ implementation to count number of digits in the product of two numbers ; function to count number of digits in the product of two numbers ; absolute value of the product of two numbers ; if product is 0 ; count number of digits in the product ' p ' ; required count of digits ; Driver program to test above\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int countDigits ( int a , int b ) { int count = 0 ; int p = abs ( a * b ) ; if ( p == 0 ) return 1 ; while ( p > 0 ) { count ++ ; p = p \\/ 10 ; } return count ; } int main ( ) { int a = 33 ; int b = -24 ; cout << \\\" Number ▁ of ▁ digits ▁ = ▁ \\\" << countDigits ( a , b ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Sum of first n term of Series 3 , 5 , 9 , 17 , 33. ... | PHP program to find sum of first n terms ; Sn = n * ( 4 * n * n + 6 * n - 1 ) \\/ 3 ; number of terms to be included in sum ; find the Sn\\\"\\nSolution in php:\",\"targets\":\"< ? php function calculateSum ( $ n ) { return ( pow ( 2 , $ n + 1 ) + $ n - 2 ) ; } $ n = 4 ; echo \\\" Sum = \\\" ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Program to find parity | C program to find parity of an integer ; Function to get parity of number n . It returns 1 if n has odd parity , and returns 0 if n has even parity ; Driver program to test getParity ( )\\\"\\nSolution in C:\",\"targets\":\"# include \\n# define bool int\\nbool getParity ( unsigned int n ) { bool parity = 0 ; while ( n ) { parity = ! parity ; n = n & ( n - 1 ) ; } return parity ; } int main ( ) { unsigned int n = 7 ; printf ( \\\" Parity ▁ of ▁ no ▁ % d ▁ = ▁ % s \\\" , n , ( getParity ( n ) ? \\\" odd \\\" : \\\" even \\\" ) ) ; getchar ( ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Permute two arrays such that sum of every pair is greater or equal to K | Check whether any permutation exists which satisfy the condition . ; Sort the array a [ ] in decreasing order . ; Sort the array b [ ] in increasing order . ; Checking condition on each index . ; Driven Program\\\"\\nSolution in php:\",\"targets\":\"< ? php function isPossible ( $ a , $ b , $ n , $ k ) { sort ( $ a ) ; rsort ( $ b ) ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) if ( $ a [ $ i ] + $ b [ $ i ] < $ k ) return false ; return true ; } $ a = array ( 2 , 1 , 3 ) ; $ b = array ( 7 , 8 , 9 ) ; $ k = 10 ; $ n = count ( $ a ) ; if ( isPossible ( $ a , $ b , $ n , $ k ) ) echo \\\" Yes \\\" ; else echo \\\" No \\\" ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Kth smallest or largest element in unsorted Array | Set 4 | C # program for the above approach ; Function to find the Kth smallest element in Unsorted Array ; Initialize the max Element as 0 ; Iterate [ ] arr and find the maximum element in it ; Frequency array to store the frequencies ; Counter variable ; Counting the frequencies ; Iterate through the [ ] freq ; Check if num is present in the array ; Increment the counter with the frequency of num ; Checking if we have reached the Kth smallest element ; Return the Kth smallest element ; Driver code ; Given array ; Function call\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; using System . Collections . Generic ; class GFG { static int findKthSmallest ( int [ ] arr , int n , int k ) { int max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > max ) max = arr [ i ] ; } int [ ] counter = new int [ max + 1 ] ; int smallest = 0 ; for ( int i = 0 ; i < n ; i ++ ) { counter [ arr [ i ] ] ++ ; } for ( int num = 1 ; num <= max ; num ++ ) { if ( counter [ num ] > 0 ) { smallest += counter [ num ] ; } if ( smallest >= k ) { return num ; } } return - 1 ; } public static void Main ( String [ ] args ) { int [ ] arr = { 7 , 1 , 4 , 4 , 20 , 15 , 8 } ; int N = arr . Length ; int K = 5 ; Console . Write ( findKthSmallest ( arr , N , K ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Count ways to reach the nth stair using step 1 , 2 or 3 | A C program to count number of ways to reach n 't stair when ; A recursive function used by countWays ; Driver program to test above functions\\\"\\nSolution in C:\",\"targets\":\"#include \\nint countWays ( int n ) { int res [ n + 1 ] ; res [ 0 ] = 1 ; res [ 1 ] = 1 ; res [ 2 ] = 2 ; for ( int i = 3 ; i <= n ; i ++ ) res [ i ] = res [ i - 1 ] + res [ i - 2 ] + res [ i - 3 ] ; return res [ n ] ; } int main ( ) { int n = 4 ; printf ( \\\" % d \\\" , countWays ( n ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Diameter of a Binary Indexed Tree with N nodes | ; Function to find diameter of BIT with N + 1 nodes ; L is size of subtree just before subtree in which N lies ; H is the height of subtree just before subtree in which N lies ; Base Cases ; Size of subtree are power of 2 ; 3 Cases as explained in Approach ; Driver Code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int diameter ( int n ) { int L , H , templen ; L = 1 ; H = 0 ; if ( n == 1 ) { return 1 ; } if ( n == 2 ) { return 2 ; } if ( n == 3 ) { return 3 ; } while ( L * 2 <= n ) { L *= 2 ; H ++ ; } if ( n >= L * 2 - 1 ) return 2 * H + 1 ; else if ( n >= L + ( L \\/ 2 ) - 1 ) return 2 * H ; return 2 * H - 1 ; } int main ( ) { int n = 15 ; cout << diameter ( n ) << endl ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"Logarithm tricks for Competitive Programming | C implementation to check if the number is power of K ; Function to check if the number is power of K ; Logarithm function to calculate value ; Compare to the result1 or result2 both are equal ; Driver Code\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#include \\n_Bool isPower ( int N , int K ) { int res1 = log ( N ) \\/ log ( K ) ; double res2 = log ( N ) \\/ log ( K ) ; return ( res1 == res2 ) ; } int main ( ) { int N = 8 ; int K = 2 ; if ( isPower ( N , K ) ) { printf ( \\\" Yes \\\" ) ; } else { printf ( \\\" No \\\" ) ; } return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Longest subarray with elements divisible by k | function to find longest subarray ; This will contain length of longest subarray found ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function longestsubarray ( $ arr , $ n , $ k ) { $ current_count = 0 ; $ max_count = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { if ( $ arr [ $ i ] % $ k == 0 ) $ current_count ++ ; else $ current_count = 0 ; $ max_count = max ( $ current_count , $ max_count ) ; } return $ max_count ; } $ arr = array ( 2 , 5 , 11 , 32 , 64 , 88 ) ; $ n = sizeof ( $ arr ) ; $ k = 8 ; echo longestsubarray ( $ arr , $ n , $ k ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Ways to choose three points with distance between the most distant points <= L | Java program to count ways to choose triplets such that the distance between the farthest points <= L ; Returns the number of triplets with distance between farthest points <= L ; sort to get ordered triplets so that we can find the distance between farthest points belonging to a triplet ; generate and check for all possible triplets : { arr [ i ] , arr [ j ] , arr [ k ] } ; Since the array is sorted the farthest points will be a [ i ] and a [ k ] ; ; Driver Code ; set of n points on the X axis\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . io . * ; import java . util . Arrays ; class GFG { static int countTripletsLessThanL ( int n , int L , int [ ] arr ) { Arrays . sort ( arr ) ; int ways = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { for ( int k = j + 1 ; k < n ; k ++ ) { int mostDistantDistance = arr [ k ] - arr [ i ] ; if ( mostDistantDistance <= L ) { ways ++ ; } } } } return ways ; } static public void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int n = arr . length ; int L = 3 ; int ans = countTripletsLessThanL ( n , L , arr ) ; System . out . println ( \\\" Total ▁ Number ▁ of ▁ ways ▁ = ▁ \\\" + ans ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Minimum digits to remove to make a number Perfect Square | Java program to find required minimum digits need to remove to make a number perfect square ; function to check minimum number of digits should be removed to make this number a perfect square ; size of the string ; our final answer ; to store string which is perfect square . ; We make all possible subsequences ; to check jth bit is set or not . ; we do not consider a number with leading zeros ; convert our temporary string into integer ; checking temp is perfect square or not . ; taking maximum sized string ; print PerfectSquare ; Driver code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . io . * ; import java . lang . * ; public class GFG { static int perfectSquare ( String s ) { int n = s . length ( ) ; int ans = - 1 ; String num = \\\" \\\" ; for ( int i = 1 ; i < ( 1 << n ) ; i ++ ) { String str = \\\" \\\" ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( ( i >> j ) & 1 ) == 1 ) { str += s . charAt ( j ) ; } } if ( str . charAt ( 0 ) != '0' ) { int temp = 0 ; for ( int j = 0 ; j < str . length ( ) ; j ++ ) temp = temp * 10 + ( int ) ( str . charAt ( j ) - '0' ) ; int k = ( int ) Math . sqrt ( temp ) ; if ( k * k == temp ) { if ( ans < ( int ) str . length ( ) ) { ans = ( int ) str . length ( ) ; num = str ; } } } } if ( ans == - 1 ) return ans ; else { System . out . print ( num + \\\" ▁ \\\" ) ; return n - ans ; } } public static void main ( String args [ ] ) { System . out . println ( perfectSquare ( \\\"8314\\\" ) ) ; System . out . println ( perfectSquare ( \\\"753\\\" ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"Program to find whether a no is power of two | ; Function to check if x is power of 2 ; Driver program to test above function\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#include \\nbool isPowerOfTwo ( int n ) { if ( n == 0 ) return 0 ; while ( n != 1 ) { if ( n % 2 != 0 ) return 0 ; n = n \\/ 2 ; } return 1 ; } int main ( ) { isPowerOfTwo ( 31 ) ? printf ( \\\" Yes \\n \\\" ) : printf ( \\\" No \\n \\\" ) ; isPowerOfTwo ( 64 ) ? printf ( \\\" Yes \\n \\\" ) : printf ( \\\" No \\n \\\" ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Count numbers with unit digit k in given range | Returns count of numbers with k as last digit . ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function counLastDigitK ( $ low , $ high , $ k ) { $ count = 0 ; for ( $ i = $ low ; $ i <= $ high ; $ i ++ ) if ( $ i % 10 == $ k ) $ count ++ ; return $ count ; } $ low = 3 ; $ high = 35 ; $ k = 3 ; echo counLastDigitK ( $ low , $ high , $ k ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Check if Decimal representation of given Binary String is divisible by K or not | Function to check the binary number is divisible by K ; Array poweroftwo will store pow ( 2 , i ) % k ; Initializing the first element in Array ; Storing every pow ( 2 , i ) % k value in the array ; To store the remaining ; Iterating till N ; If current bit is 1 ; Updating rem ; If completely divisible ; If not Completely divisible ; Given Input ; length of string s ; Function Call\\\"\\nSolution in Javascript:\",\"targets\":\"function divisibleByk ( s , n , k ) { let poweroftwo = new Array ( n ) ; poweroftwo [ 0 ] = 1 % k ; for ( let i = 1 ; i < n ; i ++ ) { poweroftwo [ i ] = ( poweroftwo [ i - 1 ] * ( 2 % k ) ) % k ; } let rem = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( s [ n - i - 1 ] == ' ' ) { rem += ( poweroftwo [ i ] ) ; rem %= k ; } } if ( rem == 0 ) { return \\\" \\\" ; } else return \\\" \\\" ; } let s = \\\" \\\" ; let k = 9 ; let n = s . length ; document . write ( divisibleByk ( s , n , k ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Sort an Array which contain 1 to N values in O ( N ) using Cycle Sort | C # program for the above approach ; Function to print array element ; Traverse the array ; Function to sort the array in O ( N ) ; Traverse the array ; If the current element is at correct position ; Else swap the current element with it 's correct position ; Swap the value of arr [ i ] and arr [ arr [ i ] - 1 ] ; Driver Code ; Function call to sort the array ; Function call to print the array\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { public static void printArray ( int [ ] arr , int N ) { for ( int i = 0 ; i < N ; i ++ ) { Console . Write ( arr [ i ] + \\\" ▁ \\\" ) ; } } public static void sortArray ( int [ ] arr , int N ) { for ( int i = 0 ; i < N ; ) { if ( arr [ i ] == i + 1 ) { i ++ ; } else { int temp1 = arr [ i ] ; int temp2 = arr [ arr [ i ] - 1 ] ; arr [ i ] = temp2 ; arr [ temp1 - 1 ] = temp1 ; } } } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 1 , 5 , 3 , 4 } ; int N = arr . Length ; sortArray ( arr , N ) ; printArray ( arr , N ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Sum of series with alternate signed squares of AP | function to calculate series sum ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function seiresSum ( $ n , $ a ) { $ res = 0 ; for ( $ i = 0 ; $ i < 2 * $ n ; $ i ++ ) { if ( $ i % 2 == 0 ) $ res += $ a [ $ i ] * $ a [ $ i ] ; else $ res -= $ a [ $ i ] * $ a [ $ i ] ; } return $ res ; } $ n = 2 ; $ a = array ( 1 , 2 , 3 , 4 ) ; echo seiresSum ( $ n , $ a ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Number of pairs of lines having integer intersection points | C ++ program to Number of pairs of lines having integer intersection points ; Count number of pairs of lines having integer intersection point ; Initialize arrays to store counts ; Count number of odd and even Pi ; Count number of odd and even Qi ; Return the count of pairs ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int countPairs ( int * P , int * Q , int N , int M ) { int A [ 2 ] = { 0 } , B [ 2 ] = { 0 } ; for ( int i = 0 ; i < N ; i ++ ) A [ P [ i ] % 2 ] ++ ; for ( int i = 0 ; i < M ; i ++ ) B [ Q [ i ] % 2 ] ++ ; return ( A [ 0 ] * B [ 0 ] + A [ 1 ] * B [ 1 ] ) ; } int main ( ) { int P [ ] = { 1 , 3 , 2 } , Q [ ] = { 3 , 0 } ; int N = sizeof ( P ) \\/ sizeof ( P [ 0 ] ) ; int M = sizeof ( Q ) \\/ sizeof ( Q [ 0 ] ) ; cout << countPairs ( P , Q , N , M ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Squares of numbers with repeated single digits | Set 1 ( 3 , 6 and 9 ) | Function to find the square of 333. . .333 , 666. . .666 and 999. . .999 ; if the number is 333. . .333 ; if the number is 666. . .666 ; if the number is 999. . .999 ; variable for hold result ; find the no of digit ; add size - 1 time a in result ; add one time b in result ; add size - 1 time c in result ; add one time d in result ; return result ; Drivers code ; find square of 33. .33 ; find square of 66. .66 ; find square of 66. .66\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function find_Square_369 ( $ num ) { if ( $ num [ 0 ] == '3' ) { $ a = '1' ; $ b = '0' ; $ c = '8' ; $ d = '9' ; } else if ( $ num [ 0 ] == '6' ) { $ a = '4' ; $ b = '3' ; $ c = '5' ; $ d = '6' ; } else { $ a = '9' ; $ b = '8' ; $ c = '0' ; $ d = '1' ; } $ result = \\\" \\\" ; $ size = strlen ( $ num ) ; for ( $ i = 1 ; $ i < $ size ; $ i ++ ) $ result = $ result . $ a ; $ result = $ result . $ b ; for ( $ i = 1 ; $ i < $ size ; $ i ++ ) $ result = $ result . $ c ; $ result = $ result . $ d ; return $ result ; } $ num_3 = \\\"3333\\\" ; $ num_6 = \\\"6666\\\" ; $ num_9 = \\\"9999\\\" ; $ result = \\\" \\\" ; $ result = find_Square_369 ( $ num_3 ) ; echo \\\" Square ▁ of ▁ \\\" . $ num_3 . \\\" ▁ is ▁ : ▁ \\\" . $ result . \\\" \\n \\\" ; $ result = find_Square_369 ( $ num_6 ) ; echo \\\" Square ▁ of ▁ \\\" . $ num_6 . \\\" ▁ is ▁ : ▁ \\\" . $ result . \\\" \\n \\\" ; $ result = find_Square_369 ( $ num_9 ) ; echo \\\" Square ▁ of ▁ \\\" . $ num_9 . \\\" ▁ is ▁ : ▁ \\\" . $ result . \\\" \\n \\\" ; return 0 ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Find Next number having distinct digits from the given number N | C ++ implementation to find the next distinct digits number ; Function to find the next distinct digits number ; Loop to find the distinct digits using hash array and the number of digits ; Loop to find the most significant distinct digit of the next number ; Condition to check if the number is possible with the same number of digits count ; Condition to check if the desired most siginificant distinct digit is found ; Loop to find the minimum next digit which is not present in the number ; Computation of the number ; Condition to check if the number is greater than the given number ; Driver Code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; void findNextNumber ( int n ) { int h [ 10 ] = { 0 } ; int i = 0 , msb = n , rem = 0 ; int next_num = -1 , count = 0 ; while ( msb > 9 ) { rem = msb % 10 ; h [ rem ] = 1 ; msb \\/= 10 ; count ++ ; } h [ msb ] = 1 ; count ++ ; for ( i = msb + 1 ; i < 10 ; i ++ ) { if ( h [ i ] == 0 ) { next_num = i ; break ; } } if ( next_num == -1 ) { for ( i = 1 ; i < msb ; i ++ ) { if ( h [ i ] == 0 ) { next_num = i ; count ++ ; break ; } } } if ( next_num > 0 ) { for ( i = 0 ; i < 10 ; i ++ ) { if ( h [ i ] == 0 ) { msb = i ; break ; } } for ( i = 1 ; i < count ; i ++ ) { next_num = ( ( next_num * 10 ) + msb ) ; } if ( next_num > n ) cout << next_num << \\\" \\n \\\" ; else cout << \\\" Not ▁ Possible ▁ \\n \\\" ; } else { cout << \\\" Not ▁ Possible ▁ \\n \\\" ; } } int main ( ) { int n = 2019 ; findNextNumber ( n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Mean of array generated by products of all pairs of the given array | Function to find the mean of pair product array of arr [ ] ; Initializing suffix sum array ; Build suffix sum array ; Size of pairProductArray ; Stores sum of pairProductArray ; Store the mean ; Find mean of pairProductArray ; Return the resultant mean ; Given array arr [ ] ; Function Call\\\"\\nSolution in Javascript:\",\"targets\":\"function pairProductMean ( arr , N ) { var suffixSumArray = Array ( N ) ; suffixSumArray [ N - 1 ] = arr [ N - 1 ] ; for ( var i = N - 2 ; i >= 0 ; i -- ) { suffixSumArray [ i ] = suffixSumArray [ i + 1 ] + arr [ i ] ; } var length = ( N * ( N - 1 ) ) \\/ 2 ; var res = 0 ; for ( var i = 0 ; i < N - 1 ; i ++ ) { res += arr [ i ] * suffixSumArray [ i + 1 ] ; } var mean ; if ( length != 0 ) mean = res \\/ length ; else mean = 0 ; return mean ; } var arr = [ 1 , 2 , 4 , 8 ] ; var N = arr . length ; document . write ( pairProductMean ( arr , N ) . toFixed ( 2 ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Hyperfactorial of a number | function to calculate the value of hyperfactorial ; initialise the val to 1 ; returns the hyperfactorial of a number ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"class GFG { static long boost_hyperfactorial ( long num ) { long val = 1 ; for ( int i = 1 ; i <= num ; i ++ ) { val = val * ( long ) Math . pow ( i , i ) ; } return val ; } public static void main ( String args [ ] ) { int num = 5 ; System . out . println ( boost_hyperfactorial ( num ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Find last five digits of a given five digit number raised to power five | Function to find the last five digits of a five digit number raised to power five ; Driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function lastFiveDigits ( n ) { n = ( Math . floor ( n \\/ 10000 ) ) * 10000 + ( Math . floor ( n \\/ 100 ) % 10 ) * 1000 + ( n % 10 ) * 100 + ( Math . floor ( n \\/ 10 ) % 10 ) * 10 + Math . floor ( n \\/ 1000 ) % 10 ; let ans = 1 ; for ( let i = 0 ; i < 5 ; i ++ ) { ans *= n ; ans %= 100000 ; } document . write ( ans ) ; } let n = 12345 ; lastFiveDigits ( n ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"Count words in a given string | C program to count no of words from given input string . ; returns number of words in str ; word count ; Scan all characters one by one ; If next character is a separator , set the state as OUT ; If next character is not a word separator and state is OUT , then set the state as IN and increment word count ; Move to next character ; Driver program to tes above functions\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#define OUT \\t0\\n#define IN \\t1\\nunsigned countWords ( char * str ) { int state = OUT ; unsigned wc = 0 ; while ( * str ) { if ( * str == ' ▁ ' * str == ' ' * str == ' \\t ' ) state = OUT ; else if ( state == OUT ) { state = IN ; ++ wc ; } ++ str ; } return wc ; } int main ( void ) { char str [ ] = \\\" One ▁ two \\t \\t three \\n \\t four \\t five ▁ \\\" ; printf ( \\\" No ▁ of ▁ words ▁ : ▁ % u \\\" , countWords ( str ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"How to print maximum number of A 's using given four keys | A Dynamic Programming based C ++ program to find maximum number of A 's that can be printed using four keys ; This function returns the optimal length string for N keystrokes ; The optimal string length is N when N is smaller than 7 ; An array to store result of subproblems ; To pick a breakpoint ; Initializing the optimal lengths array for uptil 6 input strokes . ; Solve all subproblems in bottom - up manner ; for any keystroke n , we will need to choose between : - 1. pressing Ctrl - V once after copying the A ' s ▁ obtained ▁ by ▁ n - 3 ▁ keystrokes . ▁ ▁ 2 . ▁ pressing ▁ Ctrl - V ▁ twice ▁ after ▁ copying ▁ the ▁ A ' s obtained by n - 4 keystrokes . 3. pressing Ctrl - V thrice after copying the A 's obtained by n-5 keystrokes. ; Driver program ; for the rest of the array we will rely on the previous entries to compute new ones\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int findoptimal ( int N ) { if ( N <= 6 ) return N ; int screen [ N ] ; int b ; int n ; for ( n = 1 ; n <= 6 ; n ++ ) screen [ n - 1 ] = n ; for ( n = 7 ; n <= N ; n ++ ) { screen [ n - 1 ] = max ( 2 * screen [ n - 4 ] , max ( 3 * screen [ n - 5 ] , 4 * screen [ n - 6 ] ) ) ; } return screen [ N - 1 ] ; } int main ( ) { int N ; for ( N = 1 ; N <= 20 ; N ++ ) printf ( \\\" Maximum ▁ Number ▁ of ▁ A ' s ▁ with ▁ % d ▁ keystrokes ▁ is ▁ % d \\n \\\" , N , findoptimal ( N ) ) ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Find the element in the matrix generated by given rules | Function to return the element in the rth row and cth column from the required matrix ; Condition for lower half of matrix ; Condition if element is in first row ; Starting element of AP in row r ; Common difference of AP in row r ; Position of element to find in AP in row r ; Driver Code\\\"\\nSolution in Javascript:\",\"targets\":\"function getElement ( N , r , c ) { if ( r > c ) return 0 ; if ( r == 1 ) { return c ; } let a = ( r + 1 ) * parseInt ( Math . pow ( 2 , ( r - 2 ) ) ) ; let d = parseInt ( Math . pow ( 2 , ( r - 1 ) ) ) ; c = c - r ; let element = a + d * c ; return element ; } let N = 4 , R = 3 , C = 4 ; document . write ( getElement ( N , R , C ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Minimum rotations required to get the same string | Java program to determine minimum number of rotations required to yield same string . ; Returns count of rotations to get the same string back . ; tmp is the concatenated string . ; substring from i index of original string size . ; if substring matches with original string then we will come out of the loop . ; Driver Method\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { static int findRotations ( String str ) { String tmp = str + str ; int n = str . length ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { String substring = tmp . substring ( i , i + str . length ( ) ) ; if ( str . equals ( substring ) ) return i ; } return n ; } public static void main ( String [ ] args ) { String str = \\\" aaaa \\\" ; System . out . println ( findRotations ( str ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Seeds ( Or Seed Roots ) of a number | Python3 program to find Seed of a number ; Stores product of digits of x in prodDig [ x ] ; If x has single digit ; If digit product is already computed ; If digit product is not computed before . ; Prints all seeds of n ; Find all seeds using prodDig [ ] ; If there was no seed ; Print seeds ; Driver code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"MAX = 10000 ;\\nprodDig = [ 0 ] * MAX ;\\ndef getDigitProduct ( x ) :\\n\\tif ( x < 10 ) :\\n\\t\\treturn x ;\\n\\tif ( prodDig [ x ] != 0 ) :\\n\\t\\treturn prodDig [ x ] ;\\n\\tprod = ( int ( x % 10 ) * getDigitProduct ( int ( x \\/ 10 ) ) ) ;\\n\\tprodDig [ x ] = prod ;\\n\\treturn prod ;\\ndef findSeed ( n ) :\\n\\tres = [ ] ;\\n\\tfor i in range ( 1 , int ( n \\/ 2 + 2 ) ) :\\n\\t\\tif ( i * getDigitProduct ( i ) == n ) :\\n\\t\\t\\tres . append ( i ) ;\\n\\tif ( len ( res ) == 0 ) :\\n\\t\\tprint ( \\\" NO ▁ seed ▁ exists \\\" ) ;\\n\\t\\treturn ;\\n\\tfor i in range ( len ( res ) ) :\\n\\t\\tprint ( res [ i ] , end = \\\" ▁ \\\" ) ;\\nn = 138 ;\\nfindSeed ( n ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Largest divisor of a number not divisible by another given number | Function to find the largest number X such that it divides P but is not divisible by Q ; Stores the frequency count of of all Prime Factors ; Increment the frequency of the current prime factor ; If Q is a prime factor ; Stores the desired result ; Iterate through all divisors of Q ; Stores the frequency count of current prime divisor on dividing P ; Count the frequency of the current prime factor ; If cur is less than frequency then P is the final result ; Iterate to get temporary answer ; Update current answer ; Print the desired result ; Given P and Q ; Function Call\\\"\\nSolution in Javascript:\",\"targets\":\"function findTheGreatestX ( P , Q ) { var divisiors = new Map ( ) ; for ( var i = 2 ; i * i <= Q ; i ++ ) { while ( Q % i == 0 && Q > 1 ) { Q = parseInt ( Q \\/ i ) ; if ( divisiors . has ( i ) ) divisiors . set ( i , divisiors . get ( i ) + 1 ) else divisiors . set ( i , 1 ) } } if ( Q > 1 ) if ( divisiors . has ( Q ) ) divisiors . set ( Q , divisiors . get ( Q ) + 1 ) else divisiors . set ( Q , 1 ) var ans = 0 ; divisiors . forEach ( ( value , key ) => { var frequency = value ; var temp = P ; var cur = 0 ; while ( temp % key == 0 ) { temp = parseInt ( temp \\/ key ) ; cur ++ ; } if ( cur < frequency ) { ans = P ; } temp = P ; for ( var j = cur ; j >= frequency ; j -- ) { temp = parseInt ( temp \\/ key ) ; } ans = Math . max ( temp , ans ) ; } ) ; document . write ( ans ) ; } var P = 10 , Q = 4 ; findTheGreatestX ( P , Q ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Longest substring such that no three consecutive characters are same | C # implementation of the approach ; Function to return the length of the longest substring such that no three consecutive characters are same ; If the length of the given string is less than 3 ; Initialize temporary and final ans to 2 as this is the minimum length of substring when length of the given string is greater than 2 ; Traverse the string from the third character to the last ; If no three consecutive characters are same then increment temporary count ; Else update the final ans and reset the temporary count ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static int maxLenSubStr ( String s ) { if ( s . Length < 3 ) return s . Length ; int temp = 2 ; int ans = 2 ; for ( int i = 2 ; i < s . Length ; i ++ ) { if ( s [ i ] != s [ i - 1 ] s [ i ] != s [ i - 2 ] ) temp ++ ; else { ans = Math . Max ( temp , ans ) ; temp = 2 ; } } ans = Math . Max ( temp , ans ) ; return ans ; } static public void Main ( ) { String s = \\\" baaabbabbb \\\" ; Console . Write ( maxLenSubStr ( s ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Check if a given Binary Tree is Heap | C ++ program to checks if a binary tree is max heap or not ; Tree node structure ; To add a new node ; Driver code ; Function call\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; struct Node { int data ; struct Node * left ; struct Node * right ; } ; struct Node * newNode ( int k ) { struct Node * node = new Node ; node -> data = k ; node -> right = node -> left = NULL ; return node ; } bool isHeap ( Node * root ) { queue < Node * > q ; q . push ( root ) ; bool nullish = false ; while ( ! q . empty ( ) ) { Node * temp = q . front ( ) ; q . pop ( ) ; if ( temp -> left ) { if ( nullish temp -> left -> data > = temp -> data ) { return false ; } q . push ( temp -> left ) ; } else { nullish = true ; } if ( temp -> right ) { if ( nullish temp -> right -> data > = temp -> data ) { return false ; } q . push ( temp -> right ) ; } else { nullish = true ; } } return true ; } int main ( ) { struct Node * root = NULL ; root = newNode ( 10 ) ; root -> left = newNode ( 9 ) ; root -> right = newNode ( 8 ) ; root -> left -> left = newNode ( 7 ) ; root -> left -> right = newNode ( 6 ) ; root -> right -> left = newNode ( 5 ) ; root -> right -> right = newNode ( 4 ) ; root -> left -> left -> left = newNode ( 3 ) ; root -> left -> left -> right = newNode ( 2 ) ; root -> left -> right -> left = newNode ( 1 ) ; if ( isHeap ( root ) ) cout << \\\" Given ▁ binary ▁ tree ▁ is ▁ a ▁ Heap \\n \\\" ; else cout << \\\" Given ▁ binary ▁ tree ▁ is ▁ not ▁ a ▁ Heap \\n \\\" ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Average of even numbers till a given even number | Function to calculate the average of even numbers ; count even numbers ; store the sum of even numbers ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function averageEven ( $ n ) { if ( $ n % 2 != 0 ) { echo ( \\\" Invalid ▁ Input \\\" ) ; return -1 ; } $ sum = 0 ; $ count = 0 ; while ( $ n >= 2 ) { $ count ++ ; $ sum += $ n ; $ n = $ n - 2 ; } return $ sum \\/ $ count ; } $ n = 16 ; echo ( averageEven ( $ n ) ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Count quadruples of given type from given array | C ++ program of the above approach ; Function to find the count of the subsequence of given type ; Stores the count of quadruples ; Generate all possible combinations of quadruples ; Check if 1 st element is equal to 3 rd element ; Check if 2 nd element is equal to 4 th element ; Driver Code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; const int maxN = 2002 ; int countSubsequece ( int a [ ] , int n ) { int i , j , k , l ; int answer = 0 ; for ( i = 0 ; i < n ; i ++ ) { for ( j = i + 1 ; j < n ; j ++ ) { for ( k = j + 1 ; k < n ; k ++ ) { for ( l = k + 1 ; l < n ; l ++ ) { if ( a [ j ] == a [ l ] && a [ i ] == a [ k ] ) { answer ++ ; } } } } } return answer ; } int main ( ) { int a [ 7 ] = { 1 , 2 , 3 , 2 , 1 , 3 , 2 } ; cout << countSubsequece ( a , 7 ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Turn off the rightmost set bit | Set 2 | C ++ program to unset the rightmost set bit ; Unsets the rightmost set bit of n and returns the result ; Checking whether bit position is set or not ; If bit position is found set , we flip this bit by xoring given number and number with bit position set ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; void FlipBits ( int n ) { for ( int bit = 0 ; bit < 32 ; bit ++ ) { if ( ( n >> bit ) & 1 ) { n = n ^ ( 1ll << bit ) ; break ; } } cout << \\\" The ▁ number ▁ after ▁ unsetting ▁ the \\\" ; cout << \\\" ▁ rightmost ▁ set ▁ bit ▁ \\\" << n ; } int main ( ) { int N = 12 ; FlipBits ( N ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Dynamic Programming | High | Returns maximum amount of task that can be done till day n ; If n is less than equal to 0 , then no solution exists ; Determines which task to choose on day n , then returns the maximum till that day ; Driver code\\\"\\nSolution in Javascript:\",\"targets\":\"function maxTasks ( high , low , n ) { if ( n <= 0 ) return 0 ; return Math . max ( high [ n - 1 ] + maxTasks ( high , low , ( n - 2 ) ) , low [ n - 1 ] + maxTasks ( high , low , ( n - 1 ) ) ) ; } let n = 5 ; let high = [ 3 , 6 , 8 , 7 , 6 ] ; let low = [ 1 , 5 , 4 , 5 , 3 ] ; document . write ( maxTasks ( high , low , n ) ) ; ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Minimum time remaining for safety alarm to start | C ++ program for the above approach ; Function to check if the value of mid as the minimum number of hours satisfies the condition ; Stores the sum of speed ; Iterate over the range [ 0 , N ] ; Find the value of speed ; If the bike is considered to be fast add it in sum ; Return the resultant sum ; Function to find the minimum number of time required ; Stores the range of Binary Search ; Stores the minimum number of time required ; Find the value of mid ; If the mid is the resultant speed required ; Update the ans and high ; Otherwise ; Return the minimum number of hours ; Driver Code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; long check ( long H [ ] , long A [ ] , long mid , long N , long M , long L ) { long sum = 0 ; for ( long i = 0 ; i < N ; i ++ ) { long speed = mid * A [ i ] + H [ i ] ; if ( speed >= L ) { sum += speed ; } } return sum ; } long buzzTime ( long N , long M , long L , long H [ ] , long A [ ] ) { long low = 0 , high = 1e10 ; long ans = 0 ; while ( high >= low ) { long mid = low + ( high - low ) \\/ 2 ; if ( check ( H , A , mid , N , M , L ) >= M ) { ans = mid ; high = mid - 1 ; } else low = mid + 1 ; } return ans ; } int main ( ) { long M = 400 , L = 120 ; long H [ ] = { 20 , 50 , 20 } ; long A [ ] = { 20 , 70 , 90 } ; long N = sizeof ( A ) \\/ sizeof ( A [ 0 ] ) ; cout << buzzTime ( N , M , L , H , A ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Ways to fill N positions using M colors such that there are exactly K pairs of adjacent different colors | Python 3 implementation of the approach ; Recursive function to find the required number of ways ; When all positions are filled ; If adjacent pairs are exactly K ; If already calculated ; Next position filled with same color ; Next position filled with different color So there can be m - 1 different colors ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"max = 4\\ndef countWays ( index , cnt , dp , n , m , k ) :\\n\\tif ( index == n ) :\\n\\t\\tif ( cnt == k ) :\\n\\t\\t\\treturn 1\\n\\t\\telse :\\n\\t\\t\\treturn 0\\n\\tif ( dp [ index ] [ cnt ] != - 1 ) :\\n\\t\\treturn dp [ index ] [ cnt ]\\n\\tans = 0\\n\\tans += countWays ( index + 1 , cnt , dp , n , m , k )\\n\\tans += ( m - 1 ) * countWays ( index + 1 , cnt + 1 , dp , n , m , k )\\n\\tdp [ index ] [ cnt ] = ans\\n\\treturn dp [ index ] [ cnt ]\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tn = 3\\n\\tm = 3\\n\\tk = 2\\n\\tdp = [ [ - 1 for x in range ( n + 1 ) ] for y in range ( max ) ]\\n\\tprint ( m * countWays ( 1 , 0 , dp , n , m , k ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Bubble Sort | An optimized version of Bubble Sort ; traverse the array from 0 to n - i - 1. Swap if the element found is greater than the next element ; IF no two elements were swapped by inner loop , then break ; Driver code to test above\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def bubbleSort ( arr ) :\\n\\tn = len ( arr )\\n\\tfor i in range ( n ) :\\n\\t\\tswapped = False\\n\\t\\tfor j in range ( 0 , n - i - 1 ) :\\n\\t\\t\\tif arr [ j ] > arr [ j + 1 ] :\\n\\t\\t\\t\\tarr [ j ] , arr [ j + 1 ] = arr [ j + 1 ] , arr [ j ]\\n\\t\\t\\t\\tswapped = True\\n\\t\\tif swapped == False :\\n\\t\\t\\tbreak\\narr = [ 64 , 34 , 25 , 12 , 22 , 11 , 90 ]\\nbubbleSort ( arr )\\nprint ( \\\" Sorted ▁ array ▁ : \\\" )\\nfor i in range ( len ( arr ) ) :\\n\\tprint ( \\\" % d \\\" % arr [ i ] , end = \\\" ▁ \\\" )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"Ternary representation of Cantor set | C implementation to find the cantor set for n levels and for a given start_num and end_num ; The Linked List Structure for the Cantor Set ; Function to initialize the Cantor Set List ; Function to propogate the list by adding new nodes for the next levels ; Modifying the start and end values for the next level ; Changing the pointers to the next node ; Recursively call the function to generate the Cantor Set for the entire level ; Function to print a level of the Set ; Function to build and display the Cantor Set for each level ; Driver code\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#include \\n#include \\ntypedef struct cantor { double start , end ; struct cantor * next ; } Cantor ; Cantor * startList ( Cantor * head , double start_num , double end_num ) { if ( head == NULL ) { head = ( Cantor * ) malloc ( sizeof ( Cantor ) ) ; head -> start = start_num ; head -> end = end_num ; head -> next = NULL ; } return head ; } Cantor * propagate ( Cantor * head ) { Cantor * temp = head ; if ( temp != NULL ) { Cantor * newNode = ( Cantor * ) malloc ( sizeof ( Cantor ) ) ; double diff = ( ( ( temp -> end ) - ( temp -> start ) ) \\/ 3 ) ; newNode -> end = temp -> end ; temp -> end = ( ( temp -> start ) + diff ) ; newNode -> start = ( newNode -> end ) - diff ; newNode -> next = temp -> next ; temp -> next = newNode ; propagate ( temp -> next -> next ) ; } return head ; } void print ( Cantor * temp ) { while ( temp != NULL ) { printf ( \\\" [ % lf ] ▁ - - ▁ [ % lf ] \\t \\\" , temp -> start , temp -> end ) ; temp = temp -> next ; } printf ( \\\" \\n \\\" ) ; } void buildCantorSet ( int A , int B , int L ) { Cantor * head = NULL ; head = startList ( head , A , B ) ; for ( int i = 0 ; i < L ; i ++ ) { printf ( \\\" Level _ % d ▁ : ▁ \\\" , i ) ; print ( head ) ; propagate ( head ) ; } printf ( \\\" Level _ % d ▁ : ▁ \\\" , L ) ; print ( head ) ; } int main ( ) { int A = 0 ; int B = 9 ; int L = 2 ; buildCantorSet ( A , B , L ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Insertion Sort | C program for insertion sort ; Function to sort an array using insertion sort ; Move elements of arr [ 0. . i - 1 ] , that are greater than key , to one position ahead of their current position ; A utility function to print an array of size n ; Driver program to test insertion sort\\\"\\nSolution in C:\",\"targets\":\"#include \\n#include \\nvoid insertionSort ( int arr [ ] , int n ) { int i , key , j ; for ( i = 1 ; i < n ; i ++ ) { key = arr [ i ] ; j = i - 1 ; while ( j >= 0 && arr [ j ] > key ) { arr [ j + 1 ] = arr [ j ] ; j = j - 1 ; } arr [ j + 1 ] = key ; } } void printArray ( int arr [ ] , int n ) { int i ; for ( i = 0 ; i < n ; i ++ ) printf ( \\\" % d ▁ \\\" , arr [ i ] ) ; printf ( \\\" \\n \\\" ) ; } int main ( ) { int arr [ ] = { 12 , 11 , 13 , 5 , 6 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; insertionSort ( arr , n ) ; printArray ( arr , n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Largest gap in an array | A C ++ program to find largest gap between two elements in an array . ; function to solve the given problem ; finding maximum and minimum of an array ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int solve ( int a [ ] , int n ) { int min1 = a [ 0 ] ; int max1 = a [ 0 ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] > max1 ) max1 = a [ i ] ; if ( a [ i ] < min1 ) min1 = a [ i ] ; } return abs ( min1 - max1 ) ; } int main ( ) { int arr [ ] = { -1 , 2 , 3 , 4 , -10 } ; int size = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; cout << \\\" Largest ▁ gap ▁ is ▁ : ▁ \\\" << solve ( arr , size ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Total number of ways to place X and Y at n places such that no two X are together | C ++ program to find the number of ways Calculate total ways to place ' x ' and ' y ' at n places such that no two ' x ' are together ; Function to return number of ways ; for n = 1 ; for n = 2 ; iterate to find Fibonacci term ; Driver Code ; total number of places\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int ways ( int n ) { int first = 2 ; int second = 3 ; int res = 0 ; for ( int i = 3 ; i <= n ; i ++ ) { res = first + second ; first = second ; second = res ; } return res ; } int main ( ) { int n = 7 ; cout << \\\" Total ▁ ways ▁ are ▁ : ▁ \\\" ; cout << ways ( n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Program to get the Sum of series : 1 | C program to get the sum of the series ; Function to get the series ; Sum of n - 1 terms starting from 2 nd term ; Driver Code\\\"\\nSolution in C:\",\"targets\":\"#include \\n#include \\ndouble Series ( double x , int n ) { double sum = 1 , term = 1 , fct , j , y = 2 , m ; int i ; for ( i = 1 ; i < n ; i ++ ) { fct = 1 ; for ( j = 1 ; j <= y ; j ++ ) { fct = fct * j ; } term = term * ( -1 ) ; m = term * pow ( x , y ) \\/ fct ; sum = sum + m ; y += 2 ; } return sum ; } int main ( ) { double x = 9 ; int n = 10 ; printf ( \\\" % .4f \\\" , Series ( x , n ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Tridecagonal Number | C ++ program to find N - th Tridecagonal number ; Function to find N - th Tridecagonal number ; Formula to calculate nth Tridecagonal number ; Driver Code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int Tridecagonal_num ( int n ) { return ( 11 * n * n - 9 * n ) \\/ 2 ; } int main ( ) { int n = 3 ; cout << Tridecagonal_num ( n ) << endl ; n = 10 ; cout << Tridecagonal_num ( n ) << endl ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Compute nCr % p | Set 1 ( Introduction and Dynamic Programming Solution ) | Returns nCr % p ; Optimization for the cases when r is large ; The array C is going to store last row of pascal triangle at the end . And last entry of last row is nCr ; Top row of Pascal Triangle ; One by constructs remaining rows of Pascal Triangle from top to bottom ; Fill entries of current row using previous row values ; nCj = ( n - 1 ) Cj + ( n - 1 ) C ( j - 1 ) ; ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function nCrModp ( $ n , $ r , $ p ) { if ( $ r > $ n - $ r ) $ r = $ n - $ r ; $ C = array ( ) ; for ( $ i = 0 ; $ i < $ r + 1 ; $ i ++ ) $ C [ $ i ] = 0 ; $ C [ 0 ] = 1 ; for ( $ i = 1 ; $ i <= $ n ; $ i ++ ) { for ( $ j = Min ( $ i , $ r ) ; $ j > 0 ; $ j -- ) $ C [ $ j ] = ( $ C [ $ j ] + $ C [ $ j - 1 ] ) % $ p ; } return $ C [ $ r ] ; } $ n = 10 ; $ r = 2 ; $ p = 13 ; echo \\\" Value ▁ of ▁ nCr ▁ % ▁ p ▁ is ▁ \\\" , nCrModp ( $ n , $ r , $ p ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Average of a stream of numbers | Returns the new average after including x ; Prints average of a stream of numbers ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"def getAvg ( prev_avg , x , n ) :\\n\\treturn ( ( prev_avg * n + x ) \\/ ( n + 1 ) ) ;\\ndef streamAvg ( arr , n ) :\\n\\tavg = 0 ;\\n\\tfor i in range ( n ) :\\n\\t\\tavg = getAvg ( avg , arr [ i ] , i ) ;\\n\\t\\tprint ( \\\" Average ▁ of ▁ \\\" , i + 1 , \\\" ▁ numbers ▁ is ▁ \\\" , avg ) ;\\narr = [ 10 , 20 , 30 , 40 , 50 , 60 ] ;\\nn = len ( arr ) ;\\nstreamAvg ( arr , n ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Check if a pair with given product exists in Linked list | Java code to find the pair with given product ; Link list node ; Given a reference ( pointer to pointer ) to the head of a list and an int , push a new node on the front of the list . ; Function to check if pair with given product exists in the list Takes head pointer of the linked list and product ; Check if pair exits ; Driver program to test above function ; Start with the empty list ; Use push ( ) to construct linked list ; function to print the result\\\"\\nSolution in Java:\",\"targets\":\"import java . util . * ; class Solution { static final int MAX = 100000 ; static class Node { int data ; Node next ; } static Node push ( Node head_ref , int new_data ) { Node new_node = new Node ( ) ; new_node . data = new_data ; new_node . next = ( head_ref ) ; ( head_ref ) = new_node ; return head_ref ; } static boolean check_pair_product ( Node head , int prod ) { Vector < Integer > s = new Vector < Integer > ( ) ; Node p = head ; while ( p != null ) { int curr = p . data ; if ( ( prod % curr == 0 ) && ( s . contains ( prod \\/ curr ) ) ) { System . out . print ( curr + \\\" ▁ \\\" + ( prod \\/ curr ) ) ; return true ; } s . add ( p . data ) ; p = p . next ; } return false ; } public static void main ( String args [ ] ) { Node head = null ; head = push ( head , 1 ) ; head = push ( head , 2 ) ; head = push ( head , 1 ) ; head = push ( head , 12 ) ; head = push ( head , 1 ) ; head = push ( head , 18 ) ; head = push ( head , 47 ) ; head = push ( head , 16 ) ; head = push ( head , 12 ) ; head = push ( head , 14 ) ; boolean res = check_pair_product ( head , 24 ) ; if ( res == false ) System . out . println ( \\\" NO ▁ PAIR ▁ EXIST \\\" ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Check if two arrays can be made equal by reversing subarrays multiple times | C implementation to check if two arrays can be made equal ; Function to check if array B can be made equal to array A ; Sort both arrays ; Check both arrays equal or not ; Driver Code\\\"\\nSolution in C:\",\"targets\":\"#include \\n#include \\nint sort ( int a [ ] , int n ) { int i , j , tmp ; for ( i = 0 ; i < n ; i ++ ) { for ( j = i + 1 ; j < n ; j ++ ) { if ( a [ j ] < a [ i ] ) { tmp = a [ i ] ; a [ i ] = a [ j ] ; a [ j ] = tmp ; } } } return 0 ; } int canMadeEqual ( int A [ ] , int B [ ] , int n ) { int i ; sort ( A , n ) ; sort ( B , n ) ; for ( i = 0 ; i < n ; i ++ ) { if ( A [ i ] != B [ i ] ) { return ( 0 ) ; } } return ( 1 ) ; } int main ( ) { int A [ ] = { 1 , 2 , 3 } ; int n ; int B [ ] = { 1 , 3 , 2 } ; n = sizeof ( A ) \\/ sizeof ( A [ 0 ] ) ; if ( canMadeEqual ( A , B , n ) ) { printf ( \\\" Yes \\\" ) ; } else { printf ( \\\" No \\\" ) ; } return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Count new pairs of strings that can be obtained by swapping first characters of pairs of strings from given array | Function to count newly created pairs by swapping the first characters of any pairs of strings ; Stores the count all possible pair of strings ; Push all the strings into the Unordered Map ; Generate all possible pairs of strings from the array arr [ ] ; Store the current pair of strings ; Swap the first character ; Check if both string are not present in map ; Print the result ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def countStringPairs ( a , n ) :\\n\\tans = 0\\n\\ts = { }\\n\\tfor i in range ( n ) :\\n\\t\\ts [ a [ i ] ] = s . get ( a [ i ] , 0 ) + 1\\n\\tfor i in range ( n ) :\\n\\t\\tfor j in range ( i + 1 , n ) :\\n\\t\\t\\tp = [ i for i in a [ i ] ]\\n\\t\\t\\tq = [ j for j in a [ j ] ]\\n\\t\\t\\tif ( p [ 0 ] != q [ 0 ] ) :\\n\\t\\t\\t\\tp [ 0 ] , q [ 0 ] = q [ 0 ] , p [ 0 ]\\n\\t\\t\\t\\tif ( ( \\\" \\\" . join ( p ) not in s ) and ( \\\" \\\" . join ( q ) not in s ) ) :\\n\\t\\t\\t\\t\\tans += 1\\n\\tprint ( ans )\\nif __name__ == ' _ _ main _ _ ' :\\n\\tarr = [ \\\" good \\\" , \\\" bad \\\" , \\\" food \\\" ]\\n\\tN = len ( arr )\\n\\tcountStringPairs ( arr , N )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Maximum number of 2 x2 squares that can be fit inside a right isosceles triangle | C # program to count number of 2 x 2 squares in a right isosceles triangle ; removing the extra part we would always need ; Since each square has base of length of 2 ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { public static int numberOfSquares ( int _base ) { _base = ( _base - 2 ) ; _base = _base \\/ 2 ; return _base * ( _base + 1 ) \\/ 2 ; } public static void Main ( ) { int _base = 8 ; Console . WriteLine ( numberOfSquares ( _base ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Maximise array sum after taking non | Python3 implementation of the approach ; To store the states of dp ; To check if a given state has been solved ; To store the prefix - sum ; Function to fill the prefix_sum [ ] with the prefix sum of the given array ; Function to find the maximum sum subsequence such that no two elements are adjacent ; Base case ; To check if a state has been solved ; Required recurrence relation ; Returning the value ; Driver code ; Finding prefix - sum ; Finding the maximum possible sum\\\"\\nSolution in Python:\",\"targets\":\"maxLen = 10\\ndp = [ 0 ] * maxLen ;\\nv = [ 0 ] * maxLen ;\\nprefix_sum = [ 0 ] * maxLen ;\\ndef findPrefixSum ( arr , n ) :\\n\\tprefix_sum [ 0 ] = arr [ 0 ] ;\\n\\tfor i in range ( n ) :\\n\\t\\tprefix_sum [ i ] = arr [ i ] + prefix_sum [ i - 1 ] ;\\ndef maxSum ( arr , i , n , k ) :\\n\\tif ( i + k > n ) :\\n\\t\\treturn 0 ;\\n\\tif ( v [ i ] ) :\\n\\t\\treturn dp [ i ] ;\\n\\tv [ i ] = 1 ;\\n\\tif ( i == 0 ) :\\n\\t\\tx = prefix_sum [ k - 1 ] ;\\n\\telse :\\n\\t\\tx = prefix_sum [ i + k - 1 ] - prefix_sum [ i - 1 ] ;\\n\\tdp [ i ] = max ( maxSum ( arr , i + 1 , n , k ) , x + maxSum ( arr , i + k + 1 , n , k ) ) ;\\n\\treturn dp [ i ] ;\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tarr = [ 1 , 3 , 7 , 6 ] ;\\n\\tn = len ( arr ) ;\\n\\tk = 1 ;\\n\\tfindPrefixSum ( arr , n ) ;\\n\\tprint ( maxSum ( arr , 0 , n , k ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Program to find the number of men initially | C ++ implementation of above approach . ; Function to return the number of men initially ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int numberOfMen ( int D , int m , int d ) { int Men = ( m * ( D - d ) ) \\/ d ; return Men ; } int main ( ) { int D = 5 , m = 4 , d = 4 ; cout << numberOfMen ( D , m , d ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Selection Sort | Java program for implementation of Selection Sort ; sort function ; One by one move boundary of unsorted subarray ; Find the minimum element in unsorted array ; Swap the found minimum element with the first element ; Prints the array ; Driver code to test above\\\"\\nSolution in Java:\",\"targets\":\"class SelectionSort { void sort ( int arr [ ] ) { int n = arr . length ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int min_idx = i ; for ( int j = i + 1 ; j < n ; j ++ ) if ( arr [ j ] < arr [ min_idx ] ) min_idx = j ; int temp = arr [ min_idx ] ; arr [ min_idx ] = arr [ i ] ; arr [ i ] = temp ; } } void printArray ( int arr [ ] ) { int n = arr . length ; for ( int i = 0 ; i < n ; ++ i ) System . out . print ( arr [ i ] + \\\" ▁ \\\" ) ; System . out . println ( ) ; } public static void main ( String args [ ] ) { SelectionSort ob = new SelectionSort ( ) ; int arr [ ] = { 64 , 25 , 12 , 22 , 11 } ; ob . sort ( arr ) ; System . out . println ( \\\" Sorted ▁ array \\\" ) ; ob . printArray ( arr ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Minimum operations to make all elements equal using the second array | Java implementation to find the minimum operations make all elements equal using the second array ; Function to find the minimum operations required to make all elements of the array equal ; Minimum element of A [ ] ; Traverse through all final values ; Variable indicating whether all elements can be converted to x or not ; Total operations ; Traverse through all array elements ; All elements can 't be converted to x ; Driver Code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { static int minOperations ( int a [ ] , int b [ ] , int n ) { int minA = Arrays . stream ( a ) . min ( ) . getAsInt ( ) ; for ( int x = minA ; x >= 0 ; x -- ) { boolean check = true ; int operations = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( x % b [ i ] == a [ i ] % b [ i ] ) { operations += ( a [ i ] - x ) \\/ b [ i ] ; } else { check = false ; break ; } } if ( check ) return operations ; } return - 1 ; } public static void main ( String [ ] args ) { int N = 5 ; int A [ ] = { 5 , 7 , 10 , 5 , 15 } ; int B [ ] = { 2 , 2 , 1 , 3 , 5 } ; System . out . print ( minOperations ( A , B , N ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Sparse Table | C ++ program to do range minimum query using sparse table ; lookup [ i ] [ j ] is going to store GCD of arr [ i . . j ] . Ideally lookup table size should not be fixed and should be determined using n Log n . It is kept constant to keep code simple . ; it builds sparse table . ; GCD of single element is element itself ; Build sparse table ; Returns GCD of arr [ L . . R ] ; Find highest power of 2 that is smaller than or equal to count of elements in given range . For [ 2 , 10 ] , j = 3 ; Compute GCD of last 2 ^ j elements with first 2 ^ j elements in range . For [ 2 , 10 ] , we find GCD of arr [ lookup [ 0 ] [ 3 ] ] and arr [ lookup [ 3 ] [ 3 ] ] , ; Driver program\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; #define MAX 500\\nint table [ MAX ] [ MAX ] ; void buildSparseTable ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) table [ i ] [ 0 ] = arr [ i ] ; for ( int j = 1 ; j <= n ; j ++ ) for ( int i = 0 ; i <= n - ( 1 << j ) ; i ++ ) table [ i ] [ j ] = __gcd ( table [ i ] [ j - 1 ] , table [ i + ( 1 << ( j - 1 ) ) ] [ j - 1 ] ) ; } int query ( int L , int R ) { int j = ( int ) log2 ( R - L + 1 ) ; return __gcd ( table [ L ] [ j ] , table [ R - ( 1 << j ) + 1 ] [ j ] ) ; } int main ( ) { int a [ ] = { 7 , 2 , 3 , 0 , 5 , 10 , 3 , 12 , 18 } ; int n = sizeof ( a ) \\/ sizeof ( a [ 0 ] ) ; buildSparseTable ( a , n ) ; cout << query ( 0 , 2 ) << endl ; cout << query ( 1 , 3 ) << endl ; cout << query ( 4 , 5 ) << endl ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Bitwise OR ( or | ) of a range | C ++ Program to find the bitwise OR of all the integers in range L - R ; Returns the Most Significant Bit Position ( MSB ) ; Returns the Bitwise OR of all integers between L and R ; Find the MSB position in L ; Find the MSB position in R ; Add this value until msb_p1 and msb_p2 are same ; ; Calculate msb_p1 and msb_p2 ; Find the max of msb_p1 and msb_p2 ; Set all the bits from msb_p1 upto 0 th bit in the result ; Driver Code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int MSBPosition ( long long int N ) { int msb_p = -1 ; while ( N ) { N = N >> 1 ; msb_p ++ ; } return msb_p ; } long long int findBitwiseOR ( long long int L , long long int R ) { long long int res = 0 ; int msb_p1 = MSBPosition ( L ) ; int msb_p2 = MSBPosition ( R ) ; while ( msb_p1 == msb_p2 ) { long long int res_val = ( 1 << msb_p1 ) ; res += res_val ; L -= res_val ; R -= res_val ; msb_p1 = MSBPosition ( L ) ; msb_p2 = MSBPosition ( R ) ; } msb_p1 = max ( msb_p1 , msb_p2 ) ; for ( int i = msb_p1 ; i >= 0 ; i -- ) { long long int res_val = ( 1 << i ) ; res += res_val ; } return res ; } int main ( ) { int L = 12 , R = 18 ; cout << findBitwiseOR ( L , R ) << endl ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Modular multiplicative inverse from 1 to n | A naive method to find modular multiplicative inverse of ' a ' under modulo ' prime ' ; Driver Program\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function modInverse ( int $ a , int $ prime ) { $ a = $ a % $ prime ; for ( $ x = 1 ; $ x < $ prime ; $ x ++ ) if ( ( $ a * $ x ) % $ prime == 1 ) return $ x ; return -1 ; } function printModIverses ( $ n , $ prime ) { for ( $ i = 1 ; $ i <= $ n ; $ i ++ ) echo modInverse ( $ i , $ prime ) , \\\" ▁ \\\" ; } $ n = 10 ; $ prime = 17 ; printModIverses ( $ n , $ prime ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Maximum trace possible for any sub | PHP implementation of the approach ; Function to return the maximum trace possible for a sub - matrix of the given matrix ; Calculate the trace for each of the sub - matrix with top left corner at cell ( r , s ) ; Update the maximum trace ; Return the maximum trace ; Driver code\\\"\\nSolution in php:\",\"targets\":\"< ? php $ N = 3 ; function MaxTraceSub ( $ mat ) { global $ N ; $ max_trace = 0 ; for ( $ i = 0 ; $ i < $ N ; $ i ++ ) { for ( $ j = 0 ; $ j < $ N ; $ j ++ ) { $ r = $ i ; $ s = $ j ; $ trace = 0 ; while ( $ r < $ N && $ s < $ N ) { $ trace += $ mat [ $ r ] [ $ s ] ; $ r ++ ; $ s ++ ; $ max_trace = max ( $ trace , $ max_trace ) ; } } } return $ max_trace ; } $ mat = array ( array ( 10 , 2 , 5 ) , array ( 6 , 10 , 4 ) , array ( 2 , 7 , -10 ) ) ; print ( MaxTraceSub ( $ mat ) ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Count all distinct pairs with difference equal to k | A sorting base C # program to count pairs with difference k ; Standard binary search function ; Returns count of pairs with difference k in arr [ ] of size n . ; Sort array elements ; ; Pick a first element point ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static int binarySearch ( int [ ] arr , int low , int high , int x ) { if ( high >= low ) { int mid = low + ( high - low ) \\/ 2 ; if ( x == arr [ mid ] ) return mid ; if ( x > arr [ mid ] ) return binarySearch ( arr , ( mid + 1 ) , high , x ) ; else return binarySearch ( arr , low , ( mid - 1 ) , x ) ; } return - 1 ; } static int countPairsWithDiffK ( int [ ] arr , int n , int k ) { int count = 0 , i ; Array . Sort ( arr ) ; \\/ * remove duplicates from arr [ ] for ( i = 0 ; i < n - 1 ; i ++ ) if ( binarySearch ( arr , i + 1 , n - 1 , arr [ i ] + k ) != - 1 ) count ++ ; return count ; } public static void Main ( ) { int [ ] arr = { 1 , 5 , 3 , 4 , 2 } ; int n = arr . Length ; int k = 3 ; Console . WriteLine ( \\\" Count ▁ of ▁ pairs ▁ with \\\" + \\\" ▁ given ▁ diff ▁ is ▁ \\\" + countPairsWithDiffK ( arr , n , k ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Find nth number that contains the digit k or divisible by k . | Java program to find nth number that contains the digit k or divisible by k . ; Function for checking if digit k is in n or not ; finding remainder ; if digit found ; Function for finding nth number ; since k is the first which satisfy th criteria , so consider it in count making count = 1 and starting from i = k + 1 ; checking that the number contain k digit or divisible by k ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"import java . io . * ; class GFG { public static boolean checkdigit ( int n , int k ) { while ( n != 0 ) { int rem = n % 10 ; if ( rem == k ) return true ; n = n \\/ 10 ; } return false ; } public static int findNthNumber ( int n , int k ) { for ( int i = k + 1 , count = 1 ; count < n ; i ++ ) { if ( checkdigit ( i , k ) || ( i % k == 0 ) ) count ++ ; if ( count == n ) return i ; } return - 1 ; } public static void main ( String [ ] args ) { int n = 10 , k = 2 ; System . out . println ( findNthNumber ( n , k ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Permutation present at the middle of lexicographic ordering of permutations of at most length N made up integers up to K | Java program for the above approach ; Function that finds the middle the lexicographical smallest sequence ; If K is even ; First element is K \\/ 2 ; Remaining elements of the sequence are all integer K ; Stores the sequence when K is odd ; Iterate over the range [ 0 , N \\/ 2 ] ; Check if the sequence ends with in 1 or not ; Remove the sequence ending in 1 ; If it doesn 't end in 1 ; Decrement by 1 ; Insert K to the sequence till its size is N ; Print the sequence stored in the vector ; Driver Code\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . io . * ; import java . util . * ; class GFG { static void lexiMiddleSmallest ( int K , int N ) { if ( K % 2 == 0 ) { System . out . print ( K \\/ 2 + \\\" ▁ \\\" ) ; for ( int i = 0 ; i < N - 1 ; ++ i ) { System . out . print ( K + \\\" ▁ \\\" ) ; } System . out . println ( ) ; return ; } ArrayList < Integer > a = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < N \\/ 2 ; ++ i ) { if ( a . get ( a . size ( ) - 1 ) == 1 ) { a . remove ( a . size ( ) - 1 ) ; } else { int t = a . get ( a . size ( ) - 1 ) - 1 ; a . set ( a . get ( a . size ( ) - 1 ) , t ) ; while ( a . size ( ) < N ) { a . add ( K ) ; } } } for ( int i : a ) { System . out . print ( i + \\\" ▁ \\\" ) ; } System . out . println ( ) ; } public static void main ( String [ ] args ) { int K = 2 , N = 4 ; lexiMiddleSmallest ( K , N ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Mirror of matrix across diagonal | Simple C # program to find mirror of matrix across diagonal . ; for diagonal which start from at first row of matrix ; traverse all top right diagonal ; here we use stack for reversing the element of diagonal ; push all element back to matrix in reverse order ; do the same process for all the diagonal which start from last column ; here we use stack for reversing the elements of diagonal ; push all element back to matrix in reverse order ; Utility function to print a matrix ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; using System . Collections . Generic ; class GFG { static int MAX = 100 ; static void imageSwap ( int [ , ] mat , int n ) { int row = 0 ; for ( int j = 0 ; j < n ; j ++ ) { Stack < int > s = new Stack < int > ( ) ; int i = row , k = j ; while ( i < n && k >= 0 ) { s . Push ( mat [ i ++ , k -- ] ) ; } i = row ; k = j ; while ( i < n && k >= 0 ) { mat [ i ++ , k -- ] = s . Peek ( ) ; s . Pop ( ) ; } } int column = n - 1 ; for ( int j = 1 ; j < n ; j ++ ) { Stack < int > s = new Stack < int > ( ) ; int i = j , k = column ; while ( i < n && k >= 0 ) { s . Push ( mat [ i ++ , k -- ] ) ; } i = j ; k = column ; while ( i < n && k >= 0 ) { mat [ i ++ , k -- ] = s . Peek ( ) ; s . Pop ( ) ; } } } static void printMatrix ( int [ , ] mat , int n ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { Console . Write ( mat [ i , j ] + \\\" ▁ \\\" ) ; } Console . WriteLine ( \\\" \\\" ) ; } } public static void Main ( String [ ] args ) { int [ , ] mat = { { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } , { 9 , 10 , 11 , 12 } , { 13 , 14 , 15 , 16 } } ; int n = 4 ; imageSwap ( mat , n ) ; printMatrix ( mat , n ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Calculate 7 n \\/ 8 without using division and multiplication operators | C program to evaluate ceil ( 7 n \\/ 8 ) without using * and \\/ ; Note the inner bracket here . This is needed because precedence of ' - ' operator is higher than ' < < ' ; Driver program to test above function\\\"\\nSolution in C:\",\"targets\":\"#include \\nint multiplyBySevenByEight ( unsigned int n ) { return ( n - ( n >> 3 ) ) ; } int main ( ) { unsigned int n = 9 ; printf ( \\\" % d \\\" , multiplyBySevenByEight ( n ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Check whether Arithmetic Progression can be formed from the given array | Java program to check if a given array can form arithmetic progression ; Returns true if a permutation of arr [ 0. . n - 1 ] can form arithmetic progression ; Sort array ; After sorting , difference between consecutive elements must be same . ; driver code\\\"\\nSolution in Java:\",\"targets\":\"import java . util . Arrays ; class GFG { static boolean checkIsAP ( int arr [ ] , int n ) { if ( n == 1 ) return true ; Arrays . sort ( arr ) ; int d = arr [ 1 ] - arr [ 0 ] ; for ( int i = 2 ; i < n ; i ++ ) if ( arr [ i ] - arr [ i - 1 ] != d ) return false ; return true ; } public static void main ( String [ ] args ) { int arr [ ] = { 20 , 15 , 5 , 0 , 10 } ; int n = arr . length ; if ( checkIsAP ( arr , n ) ) System . out . println ( \\\" Yes \\\" ) ; else System . out . println ( \\\" No \\\" ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Rearrange Array to find K using Binary Search algorithm without sorting | Function to rearrange the array ; Stores the rearranged array ; Stores whether the arrangement is possible or not ; Update K with the position of K ; Stores all elements lesser than and greater than in vector smaller and greater respectively ; Traverse the array arr [ ] ; If arr [ i ] is less than arr [ K ] ; Else ; Iterate unil low is less than or equal to high ; Stores mid point ; If mid is equal to K ; If mid is less than K ; If mid is greater than K ; If f is - 1 ; Iterate in the range [ 1 , N ] ; If ans [ i ] is equal to - 1 ; Print the rearranged array ; Driver Code ; Input ; Function Call\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def Rearrange ( arr , K , N ) :\\n\\tans = [ 0 ] * ( N + 1 )\\n\\tf = - 1\\n\\tfor i in range ( N ) :\\n\\t\\tans [ i ] = - 1\\n\\tK = arr . index ( K )\\n\\tsmaller = [ ]\\n\\tgreater = [ ]\\n\\tfor i in range ( N ) :\\n\\t\\tif ( arr [ i ] < arr [ K ] ) :\\n\\t\\t\\tsmaller . append ( arr [ i ] )\\n\\t\\telif ( arr [ i ] > arr [ K ] ) :\\n\\t\\t\\tgreater . append ( arr [ i ] )\\n\\tlow = 0\\n\\thigh = N - 1\\n\\twhile ( low <= high ) :\\n\\t\\tmid = ( low + high ) \\/\\/ 2\\n\\t\\tif ( mid == K ) :\\n\\t\\t\\tans [ mid ] = arr [ K ]\\n\\t\\t\\tf = 1\\n\\t\\t\\tbreak\\n\\t\\telif ( mid < K ) :\\n\\t\\t\\tif ( len ( smaller ) == 0 ) :\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tans [ mid ] = smaller [ - 1 ]\\n\\t\\t\\tsmaller . pop ( )\\n\\t\\t\\tlow = mid + 1\\n\\t\\telse :\\n\\t\\t\\tif ( len ( greater ) == 0 ) :\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tans [ mid ] = greater [ - 1 ]\\n\\t\\t\\tgreater . pop ( )\\n\\t\\t\\thigh = mid - 1\\n\\tif ( f == - 1 ) :\\n\\t\\tprint ( - 1 )\\n\\t\\treturn\\n\\tfor i in range ( N ) :\\n\\t\\tif ( ans [ i ] == - 1 ) :\\n\\t\\t\\tif ( len ( smaller ) ) :\\n\\t\\t\\t\\tans [ i ] = smaller [ - 1 ]\\n\\t\\t\\t\\tsmaller . pop ( )\\n\\t\\t\\telif ( len ( greater ) ) :\\n\\t\\t\\t\\tans [ i ] = greater [ - 1 ]\\n\\t\\t\\t\\tgreater . pop ( )\\n\\tfor i in range ( N ) :\\n\\t\\tprint ( ans [ i ] , end = \\\" ▁ \\\" )\\n\\tprint ( )\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tarr = [ 10 , 7 , 2 , 5 , 3 , 8 ]\\n\\tK = 7\\n\\tN = len ( arr )\\n\\tRearrange ( arr , K , N )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Find the mean vector of a Matrix | PHP program to find mean vector of given matrix ; Function to find mean vector ; loop to traverse each column ; to calculate mean of each row ; to store sum of elements of a column ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php $ rows = 3 ; $ cols = 3 ; function meanVector ( $ mat ) { global $ rows , $ cols ; echo \\\" [ ▁ \\\" ; for ( $ i = 0 ; $ i < $ rows ; $ i ++ ) { $ mean = 0.00 ; $ sum = 0 ; for ( $ j = 0 ; $ j < $ cols ; $ j ++ ) $ sum += $ mat [ $ j ] [ $ i ] ; $ mean = $ sum \\/ $ rows ; echo $ mean , \\\" \\\" ; ▁ } ▁ echo ▁ \\\" ] \\\" } $ mat = array ( array ( 1 , 2 , 3 ) , array ( 4 , 5 , 6 ) , array ( 7 , 8 , 9 ) ) ; meanVector ( $ mat ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"Maximum sum such that no two elements are adjacent | ; Function to return max sum such that no two elements are adjacent ; current max excluding i ; current max including i ; return max of incl and excl ; Driver program to test above function\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint FindMaxSum ( int arr [ ] , int n ) { int incl = arr [ 0 ] ; int excl = 0 ; int excl_new ; int i ; for ( i = 1 ; i < n ; i ++ ) { excl_new = ( incl > excl ) ? incl : excl ; incl = excl + arr [ i ] ; excl = excl_new ; } return ( ( incl > excl ) ? incl : excl ) ; } int main ( ) { int arr [ ] = { 5 , 5 , 10 , 100 , 10 , 5 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; printf ( \\\" % d ▁ n \\\" , FindMaxSum ( arr , n ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Check if given number is perfect square | PHP program to find if x is a perfect square . ; Find floating point value of square root of x . ; If square root is an integer ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function isPerfectSquare ( $ x ) { $ sr = sqrt ( $ x ) ; return ( ( $ sr - floor ( $ sr ) ) == 0 ) ; } $ x = 2502 ; if ( isPerfectSquare ( $ x ) ) echo ( \\\" Yes \\\" ) ; else echo ( \\\" No \\\" ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Sum of squares of first n natural numbers | Return the sum of square of first n natural numbers ; Iterate i from 1 and n finding square of i and add to sum . ; Driven Program\\\"\\nSolution in Javascript:\",\"targets\":\"function squaresum ( n ) { let sum = 0 ; for ( let i = 1 ; i <= n ; i ++ ) sum += ( i * i ) ; return sum ; } let n = 4 ; document . write ( squaresum ( n ) + \\\" \\\" ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Maximize the value of A by replacing some of its digits with digits of B | C # implementation of the approach ; Function to return the maximized value of A ; Sort digits in ascending order ; j points to largest digit in B ; If all the digits of b have been used ; Current digit has been used ; Return the maximized value ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static String maxValue ( char [ ] a , char [ ] b ) { Array . Sort ( b ) ; int n = a . Length ; int m = b . Length ; int j = m - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( j < 0 ) break ; if ( b [ j ] > a [ i ] ) { a [ i ] = b [ j ] ; j -- ; } } return String . Join ( \\\" \\\" , a ) ; } public static void Main ( String [ ] args ) { String a = \\\"1234\\\" ; String b = \\\"4321\\\" ; Console . Write ( maxValue ( a . ToCharArray ( ) , b . ToCharArray ( ) ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Find the sum of first N odd Fibonacci numbers | PHP program to Find the sum of first N odd Fibonacci numbers ; Function to calculate sum of first N odd Fibonacci numbers ; base values ; Driver code\\\"\\nSolution in php:\",\"targets\":\"< ? php $ mod = 1000000007 ; function sumOddFibonacci ( $ n ) { global $ mod ; $ Sum [ $ n + 1 ] = array ( ) ; $ Sum [ 0 ] = 0 ; $ Sum [ 1 ] = 1 ; $ Sum [ 2 ] = 2 ; $ Sum [ 3 ] = 5 ; $ Sum [ 4 ] = 10 ; $ Sum [ 5 ] = 23 ; for ( $ i = 6 ; $ i <= $ n ; $ i ++ ) { $ Sum [ $ i ] = ( ( $ Sum [ $ i - 1 ] + ( 4 * $ Sum [ $ i - 2 ] ) % $ mod - ( 4 * $ Sum [ $ i - 3 ] ) % $ mod + $ mod ) % $ mod + ( $ Sum [ $ i - 4 ] - $ Sum [ $ i - 5 ] + $ mod ) % $ mod ) % $ mod ; } return $ Sum [ $ n ] ; } $ n = 6 ; echo sumOddFibonacci ( $ n ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Count of Perfect Numbers in given range for Q queries | C ++ program for the above approach ; Function to check whether a number is perfect Number ; Stores sum of divisors ; Itearate over the range [ 2 , sqrt ( N ) ] ; If sum of divisors is equal to N , then N is a perfect number ; Function to find count of perfect numbers in a given range ; Stores the count of perfect Numbers upto a every number less than MAX ; Iterate over the range [ 1 , MAX ] ; Traverse the array arr [ ] ; Print the count of perfect numbers in the range [ arr [ i ] [ 0 ] , arr [ i ] [ 1 ] ] ; Driver Code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; const int MAX = 100005 ; bool isPerfect ( long long int N ) { long long int sum = 1 ; for ( long long int i = 2 ; i * i <= N ; i ++ ) { if ( N % i == 0 ) { if ( i * i != N ) sum = sum + i + N \\/ i ; else sum = sum + i ; } } if ( sum == N && N != 1 ) return true ; return false ; } void Query ( int arr [ ] [ 2 ] , int N ) { int prefix [ MAX + 1 ] = { 0 } ; for ( int i = 2 ; i <= MAX ; i ++ ) { prefix [ i ] = prefix [ i - 1 ] + isPerfect ( i ) ; } for ( int i = 0 ; i < N ; i ++ ) { cout << prefix [ arr [ i ] [ 1 ] ] - prefix [ arr [ i ] [ 0 ] - 1 ] << \\\" ▁ \\\" ; } } int main ( ) { int arr [ ] [ 2 ] = { { 1 , 1000 } , { 1000 , 2000 } , { 2000 , 3000 } } ; int N = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; Query ( arr , N ) ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Find repeated character present first in a string | C program to find the first character that is repeated ; this is O ( N ^ 2 ) method ; Driver code\\\"\\nSolution in C:\",\"targets\":\"#include \\n#include \\nint findRepeatFirstN2 ( char * s ) { int p = -1 , i , j ; for ( i = 0 ; i < strlen ( s ) ; i ++ ) { for ( j = i + 1 ; j < strlen ( s ) ; j ++ ) { if ( s [ i ] == s [ j ] ) { p = i ; break ; } } if ( p != -1 ) break ; } return p ; } int main ( ) { char str [ ] = \\\" geeksforgeeks \\\" ; int pos = findRepeatFirstN2 ( str ) ; if ( pos == -1 ) printf ( \\\" Not ▁ found \\\" ) ; else printf ( \\\" % c \\\" , str [ pos ] ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Minimize increments required to make count of even and odd array elements equal | Function to find min operations to make even and odd count equal ; Odd size will never make odd and even counts equal ; Stores the count of even numbers in the array arr ; Stores count of odd numbers in the array arr ; Traverse the array arr ; If arr [ i ] is an even number ; Update cntEven ; Odd numbers in arr ; Return absolute difference divided by 2 ; Driver code ; Function call\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function minimumIncrement ( arr , N ) { if ( N % 2 != 0 ) { document . write ( \\\" \\\" ) ; System . exit ( 0 ) ; } var cntEven = 0 ; var cntOdd = 0 ; for ( i = 0 ; i < N ; i ++ ) { if ( arr [ i ] % 2 == 0 ) { cntEven += 1 ; } } cntOdd = N - cntEven ; return Math . abs ( cntEven - cntOdd ) \\/ 2 ; } var arr = [ 1 , 3 , 4 , 9 ] ; var N = arr . length ; document . write ( minimumIncrement ( arr , N ) ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Efficient program to print all prime factors of a given number | Program to print all prime factors ; A function to print all prime factors of a given number n ; Print the number of 2 s that divide n ; n must be odd at this point . So we can skip one element ( Note i = i + 2 ) ; While i divides n , print i and divide n ; This condition is to handle the case whien n is a prime number greater than 2 ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"import java . io . * ; import java . lang . Math ; class GFG { public static void primeFactors ( int n ) { while ( n % 2 == 0 ) { System . out . print ( 2 + \\\" ▁ \\\" ) ; n \\/= 2 ; } for ( int i = 3 ; i <= Math . sqrt ( n ) ; i += 2 ) { while ( n % i == 0 ) { System . out . print ( i + \\\" ▁ \\\" ) ; n \\/= i ; } } if ( n > 2 ) System . out . print ( n ) ; } public static void main ( String [ ] args ) { int n = 315 ; primeFactors ( n ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Probability of A winning the match when individual probabilities of hitting the target given | Function to return the probability of A winning ; p and q store the values of fractions a \\/ b and c \\/ d ; To store the winning probability of A ; Driver code\\\"\\nSolution in php:\",\"targets\":\"< ? php function getProbability ( $ a , $ b , $ c , $ d ) { $ p = $ a \\/ $ b ; $ q = $ c \\/ $ d ; $ ans = $ p * ( 1 \\/ ( 1 - ( 1 - $ q ) * ( 1 - $ p ) ) ) ; return round ( $ ans , 6 ) ; } $ a = 1 ; $ b = 2 ; $ c = 10 ; $ d = 11 ; echo getProbability ( $ a , $ b , $ c , $ d ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Generate all binary strings without consecutive 1 's | C ++ program to Generate all binary string without consecutive 1 's of size K ; A utility function generate all string without consecutive 1 'sof size K ; Print binary string without consecutive 1 's ; Terminate binary string ; If previous character is '1' then we put only 0 at end of string example str = \\\"01\\\" then new string be \\\"010\\\" ; If previous character is '0' than we put both '1' and '0' at end of string example str = \\\"00\\\" then new string \\\"001\\\" and \\\"000\\\" ; Function generate all binary string without consecutive 1 's ; Base case ; One by one stores every binary string of length K ; Generate all Binary string starts with '0' ; Generate all Binary string starts with '1' ; Driver program to test above function\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; void generateAllStringsUtil ( int K , char str [ ] , int n ) { if ( n == K ) { str [ n ] = ' \\\\0' ; cout << str << \\\" ▁ \\\" ; return ; } if ( str [ n - 1 ] == '1' ) { str [ n ] = '0' ; generateAllStringsUtil ( K , str , n + 1 ) ; } if ( str [ n - 1 ] == '0' ) { str [ n ] = '0' ; generateAllStringsUtil ( K , str , n + 1 ) ; str [ n ] = '1' ; generateAllStringsUtil ( K , str , n + 1 ) ; } } void generateAllStrings ( int K ) { if ( K <= 0 ) return ; char str [ K ] ; str [ 0 ] = '0' ; generateAllStringsUtil ( K , str , 1 ) ; str [ 0 ] = '1' ; generateAllStringsUtil ( K , str , 1 ) ; } int main ( ) { int K = 3 ; generateAllStrings ( K ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Largest right circular cylinder within a frustum | C ++ Program to find the biggest right circular cylinder that can be fit within a frustum ; Function to find the biggest right circular cylinder ; radii and height cannot be negative ; radius of right circular cylinder ; height of right circular cylinder ; volume of right circular cylinder ; Driver code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; float cyl ( float r , float R , float h ) { if ( h < 0 && r < 0 && R < 0 ) return -1 ; float r1 = r ; float h1 = h ; float V = 3.14 * pow ( r1 , 2 ) * h1 ; return V ; } int main ( ) { float r = 7 , R = 11 , h = 6 ; cout << cyl ( r , R , h ) << endl ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Minimum swaps required to make a binary string alternating | C ++ implementation of the above approach ; function to count minimum swaps required to make binary string alternating ; stores total number of ones ; stores total number of zeroes ; checking impossible condition ; odd length string ; number of even positions ; stores number of zeroes and ones at even positions ; even length string ; stores number of ones at odd and even position respectively ; Driver code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int countMinSwaps ( string s ) { int N = s . size ( ) ; int one = 0 ; int zero = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( s [ i ] == '1' ) one ++ ; else zero ++ ; } if ( one > zero + 1 zero > one + 1 ) return -1 ; if ( N % 2 ) { int num = ( N + 1 ) \\/ 2 ; int one_even = 0 , zero_even = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( i % 2 == 0 ) { if ( s [ i ] == '1' ) one_even ++ ; else zero_even ++ ; } } if ( one > zero ) return num - one_even ; else return num - zero_even ; } else { int one_odd = 0 , one_even = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( s [ i ] == '1' ) { if ( i % 2 ) one_odd ++ ; else one_even ++ ; } } return min ( N \\/ 2 - one_odd , N \\/ 2 - one_even ) ; } } int main ( ) { string s = \\\"111000\\\" ; cout << countMinSwaps ( s ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Program to find area of a Circular Segment | Java Program to find area of segment of a circle ; Function to find area of segment ; Calculating area of sector ; Calculating area of triangle ; Driver Function\\\"\\nHow can the above be solved in Java?\",\"targets\":\"class GFG { static float pi = 3.14159f ; static float area_of_segment ( float radius , float angle ) { float area_of_sector = pi * ( radius * radius ) * ( angle \\/ 360 ) ; float area_of_triangle = ( float ) 1 \\/ 2 * ( radius * radius ) * ( float ) Math . sin ( ( angle * pi ) \\/ 180 ) ; return area_of_sector - area_of_triangle ; } public static void main ( String [ ] args ) { float radius = 10.0f , angle = 90.0f ; System . out . println ( \\\" Area ▁ of ▁ minor ▁ segment ▁ = ▁ \\\" + area_of_segment ( radius , angle ) ) ; System . out . println ( \\\" Area ▁ of ▁ major ▁ segment ▁ = ▁ \\\" + area_of_segment ( radius , ( 360 - angle ) ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Check if the sum of digits of a number N divides it | Function to check if sum of digits of a number divides it ; Calculate sum of all of digits of N ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function isSumDivides ( $ N ) { $ temp = $ N ; $ sum = 0 ; while ( $ temp ) { $ sum += $ temp % 10 ; $ temp = ( int ) $ temp \\/ 10 ; } if ( $ N % $ sum == 0 ) return 1 ; else return 0 ; } $ N = 12 ; if ( isSumDivides ( $ N ) ) echo \\\" YES \\\" ; else echo \\\" NO \\\" ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"Segregate 0 s and 1 s in an array | C program to sort a binary array in one pass ; Function to put all 0 s on left and all 1 s on right ; Initialize left and right indexes ; Increment left index while we see 0 at left ; Decrement right index while we see 1 at right ; If left is smaller than right then there is a 1 at left and a 0 at right . Exchange arr [ left ] and arr [ right ] ; driver program to test\\nHow can the above be solved in C?\",\"targets\":\"#include \\nvoid segregate0and1 ( int arr [ ] , int size ) { int left = 0 , right = size - 1 ; while ( left < right ) { while ( arr [ left ] == 0 && left < right ) left ++ ; while ( arr [ right ] == 1 && left < right ) right -- ; if ( left < right ) { arr [ left ] = 0 ; arr [ right ] = 1 ; left ++ ; right -- ; } } } int main ( ) { int arr [ ] = { 0 , 1 , 0 , 1 , 1 , 1 } ; int i , arr_size = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; segregate0and1 ( arr , arr_size ) ; printf ( \\\" Array ▁ after ▁ segregation ▁ \\\" ) ; for ( i = 0 ; i < 6 ; i ++ ) printf ( \\\" % d ▁ \\\" , arr [ i ] ) ; getchar ( ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Longest Common Subsequence | DP | A Naive recursive implementation of LCS problem ; Returns length of LCS for X [ 0. . m - 1 ] , Y [ 0. . n - 1 ] ; Utility function to get max of 2 integers ; Driver program to test above function\\\"\\nSolution in C:\",\"targets\":\"#include \\nint max ( int a , int b ) ; int lcs ( char * X , char * Y , int m , int n ) { if ( m == 0 n == 0 ) return 0 ; if ( X [ m - 1 ] == Y [ n - 1 ] ) return 1 + lcs ( X , Y , m - 1 , n - 1 ) ; else return max ( lcs ( X , Y , m , n - 1 ) , lcs ( X , Y , m - 1 , n ) ) ; } int max ( int a , int b ) { return ( a > b ) ? a : b ; } int main ( ) { char X [ ] = \\\" AGGTAB \\\" ; char Y [ ] = \\\" GXTXAYB \\\" ; int m = strlen ( X ) ; int n = strlen ( Y ) ; printf ( \\\" Length ▁ of ▁ LCS ▁ is ▁ % d \\\" , lcs ( X , Y , m , n ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Find the smallest missing number | ; function that returns smallest elements missing in a sorted array . ; Left half has all elements from 0 to mid ; Driver program to test the above function\\\"\\nHow can the above be solved in Java?\",\"targets\":\"class SmallestMissing { int findFirstMissing ( 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 findFirstMissing ( array , mid + 1 , end ) ; return findFirstMissing ( array , start , mid ) ; } public static void main ( String [ ] args ) { SmallestMissing small = new SmallestMissing ( ) ; int arr [ ] = { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 10 } ; int n = arr . length ; System . out . println ( \\\" First ▁ Missing ▁ element ▁ is ▁ : ▁ \\\" + small . findFirstMissing ( arr , 0 , n - 1 ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Length of longest subsequence whose XOR value is odd | C ++ program for the above approach ; Function for find max XOR subsequence having odd value ; Initialize odd and even count ; Count the number of odd and even numbers in given array ; if all values are odd in given array ; if all values are even in given array ; if both odd and even are present in given array ; Driver Code ; Given array arr [ ] ; Function Call\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int maxXORSubsequence ( int arr [ ] , int n ) { int odd = 0 , even = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] & 1 ) odd ++ ; else even ++ ; } int maxlen ; if ( odd == n ) { if ( odd % 2 == 0 ) maxlen = n - 1 ; else maxlen = n ; } else if ( even == n ) { maxlen = 0 ; } else { if ( odd % 2 == 0 ) maxlen = even + odd - 1 ; else maxlen = even + odd ; } } int main ( ) { int arr [ ] = { 2 , 3 , 4 , 5 , 6 , 7 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; cout << maxXORSubsequence ( arr , n ) ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Add elements in start to sort the array | Variation of Stalin Sort | C # implementation to sort the array by using the variation of the Stalin sort ; Function to sort the array ; Iterator < Integer > index = arr . iterator ( ) ; ; Driver Code ; Function call\\\"\\nSolution in C#:\",\"targets\":\"using System ; using System . Collections . Generic ; using System . Linq ; class GFG { static void variationStalinsort ( List < int > arr ) { int j = 0 ; while ( true ) { int moved = 0 ; for ( int i = 0 ; i < ( arr . Count - 1 - j ) ; i ++ ) { if ( arr [ i ] > arr [ i + 1 ] ) { int index ; int temp ; index = arr [ i ] ; temp = arr [ i + 1 ] ; arr . Remove ( index ) ; arr . Insert ( i , temp ) ; arr . Remove ( temp ) ; arr . Insert ( i + 1 , index ) ; moved ++ ; } } j ++ ; if ( moved == 0 ) { break ; } } foreach ( int i in arr ) Console . Write ( i + \\\" ▁ \\\" ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 2 , 1 , 4 , 3 , 6 , 5 , 8 , 7 , 10 , 9 } ; List < int > arr1 = new List < int > ( ) ; for ( int i = 0 ; i < arr . Length ; i ++ ) arr1 . Add ( arr [ i ] ) ; variationStalinsort ( arr1 ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Nearest prime less than given number n | PHP program to find the nearest prime to n . ; array to store all primes less than 10 ^ 6 ; Utility function of Sieve of Sundaram ; In general Sieve of Sundaram , produces primes smaller than ( 2 * x + 2 ) for a number given number x ; This array is used to separate numbers of the form i + j + 2 ij from others where 1 <= i <= j ; eliminate indexes which does not produce primes ; Since 2 is a prime number ; Remaining primes are of the form 2 * i + 1 such that marked [ i ] is false . ; modified binary search to find nearest prime less than N ; base condition is , if we are reaching at left corner or right corner of primes [ ] array then return that corner element because before or after that we don 't have any prime number in primes array ; now if n is itself a prime so it will be present in primes array and here we have to find nearest prime less than n so we will return primes [ mid - 1 ] ; now if primes [ mid ] < n and primes [ mid + 1 ] > n that means we reached at nearest prime ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php $ MAX = 10000 ; $ primes = array ( ) ; function Sieve ( ) { global $ MAX , $ primes ; $ n = $ MAX ; $ nNew = ( int ) ( sqrt ( $ n ) ) ; $ marked = array_fill ( 0 , ( int ) ( $ n \\/ 2 + 500 ) , 0 ) ; for ( $ i = 1 ; $ i <= ( $ nNew - 1 ) \\/ 2 ; $ i ++ ) for ( $ j = ( $ i * ( $ i + 1 ) ) << 1 ; $ j <= $ n \\/ 2 ; $ j = $ j + 2 * $ i + 1 ) $ marked [ $ j ] = 1 ; array_push ( $ primes , 2 ) ; for ( $ i = 1 ; $ i <= $ n \\/ 2 ; $ i ++ ) if ( $ marked [ $ i ] == 0 ) array_push ( $ primes , 2 * $ i + 1 ) ; } function binarySearch ( $ left , $ right , $ n ) { global $ primes ; if ( $ left <= $ right ) { $ mid = ( int ) ( ( $ left + $ right ) \\/ 2 ) ; if ( $ mid == 0 || $ mid == count ( $ primes ) - 1 ) return $ primes [ $ mid ] ; if ( $ primes [ $ mid ] == $ n ) return $ primes [ $ mid - 1 ] ; if ( $ primes [ $ mid ] < $ n && $ primes [ $ mid + 1 ] > $ n ) return $ primes [ $ mid ] ; if ( $ n < $ primes [ $ mid ] ) return binarySearch ( $ left , $ mid - 1 , $ n ) ; else return binarySearch ( $ mid + 1 , $ right , $ n ) ; } return 0 ; } Sieve ( ) ; $ n = 17 ; echo binarySearch ( 0 , count ( $ primes ) - 1 , $ n ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Count composite fibonacci numbers from given array | C # program to implement the above approach ; Function to find all Fibonacci numbers up to Max ; Store all Fibonacci numbers upto Max ; Stores previous element of Fibonacci sequence ; Stores previous element of Fibonacci sequence ; Insert prev into hashmap ; Insert all the Fibonacci numbers up to Max ; Insert curr into hashmap ; Stores curr into temp ; Update curr ; Update prev ; Function to find all Composite numbers up to Max ; isPrime [ i ] : Stores if i is a prime number or not ; Calculate all prime numbers up to Max using Sieve of Eratosthenes ; If P is a prime number ; Set all multiple of P as non - prime ; Update isPrime ; Function to find the numbers which is both a composite and Fibonacci number ; Stores the largest element of the array ; Traverse the array [ ] arr ; Update Max ; isPrim [ i ] check i is a prime number or not ; Stores all the Fibonacci numbers ; Traverse the array [ ] arr ; current element is not a composite number ; If current element is a Fibonacci and composite number ; Print current element ; Driver Code\\\"\\nSolution in C#:\",\"targets\":\"using System ; using System . Collections . Generic ; class GFG { static bool [ ] isPrime ; static HashSet < int > createhashmap ( int Max ) { HashSet < int > hashmap = new HashSet < int > ( ) ; int curr = 1 ; int prev = 0 ; hashmap . Add ( prev ) ; while ( curr < Max ) { hashmap . Add ( curr ) ; int temp = curr ; curr = curr + prev ; prev = temp ; } return hashmap ; } static void SieveOfEratosthenes ( int Max ) { isPrime = new bool [ Max ] ; for ( int i = 0 ; i < Max ; i ++ ) isPrime [ i ] = true ; isPrime [ 0 ] = false ; isPrime [ 1 ] = false ; for ( int p = 2 ; p * p <= Max ; p ++ ) { if ( isPrime [ p ] ) { for ( int i = p * p ; i <= Max ; i += p ) { isPrime [ i ] = false ; } } } } static void cntFibonacciPrime ( int [ ] arr , int N ) { int Max = arr [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { Max = Math . Max ( Max , arr [ i ] ) ; } SieveOfEratosthenes ( Max ) ; HashSet < int > hashmap = createhashmap ( Max ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 1 ) continue ; if ( ( hashmap . Contains ( arr [ i ] ) ) && ! isPrime [ arr [ i ] ] ) { Console . Write ( arr [ i ] + \\\" ▁ \\\" ) ; } } } public static void Main ( String [ ] args ) { int [ ] arr = { 13 , 55 , 7 , 3 , 5 , 21 , 233 , 144 , 89 } ; int N = arr . Length ; cntFibonacciPrime ( arr , N ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Check whether given string can be generated after concatenating given strings | Function that return true if pre is a prefix of str ; While there are characters to match ; If characters differ at any position ; str starts with pre ; Function that return true if suff is a suffix of str ; While there are characters to match ; I$f characters differ at any position ; str ends with suff ; Function that returns true if str = a + b or str = b + a ; str cannot be generated by concatenating a and b ; If str starts with a i . e . a is a prefix of str ; Check if the rest of the characters are equal to b i . e . b is a suffix of str ; If str starts with b i . e . b is a prefix of str ; Check if the rest of the characters are equal to a i . e . a is a suffix of str ; Driver code\\\"\\nSolution in php:\",\"targets\":\"< ? php function startsWith ( $ str , $ pre ) { $ strLen = strlen ( $ str ) ; $ preLen = strlen ( $ pre ) ; $ i = 0 ; $ j = 0 ; while ( $ i < $ strLen && $ j < $ preLen ) { if ( $ str [ $ i ] != $ pre [ $ j ] ) return false ; $ i ++ ; $ j ++ ; } return true ; } function endsWith ( $ str , $ suff ) { $ i = strlen ( $ str ) - 0 ; $ j = strlen ( $ suff ) - 0 ; while ( $ i >= 0 && $ j >= 0 ) { if ( $ str [ $ i ] != $ suff [ $ j ] ) return false ; $ i -- ; $ j -- ; } return true ; } function checkString ( $ str , $ a , $ b ) { if ( strlen ( $ str ) != strlen ( $ a ) + strlen ( $ b ) ) return false ; if ( startsWith ( $ str , $ a ) ) { if ( endsWith ( $ str , $ b ) ) return true ; } if ( startsWith ( $ str , $ b ) ) { if ( endsWith ( $ str , $ a ) ) return true ; } return false ; } $ str = \\\" GeeksforGeeks \\\" ; $ a = \\\" Geeksfo \\\" ; $ b = \\\" rGeeks \\\" ; if ( checkString ( $ str , $ a , $ b ) ) echo \\\" Yes \\\" ; else echo \\\" No \\\" ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Composite XOR and Coprime AND | C ++ implementation of the approach ; Function to return the count of odd numbers in the array ; Variable to count odd numbers ; Odd number ; Function to return the count of valid pairs ; Driver Code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int countOdd ( int arr [ ] , int n ) { int odd = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 1 ) odd ++ ; } return odd ; } int countValidPairs ( int arr [ ] , int n ) { int odd = countOdd ( arr , n ) ; return ( odd * ( odd - 1 ) ) \\/ 2 ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; cout << countValidPairs ( arr , n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Program for Area Of Square after N | Function to calculate area of square after given number of folds ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function areaSquare ( $ side , $ fold ) { $ area = $ side * $ side ; return $ area * 1.0 \\/ pow ( 2 , $ fold ) ; } $ side = 4 ; $ fold = 2 ; echo areaSquare ( $ side , $ fold ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"Find all factors of a natural number | Set 1 | A Better ( than Naive ) Solution to find all divisiors ; Function to print the divisors ; Note that this loop runs till square root ; If divisors are equal , print only one ; else Otherwise print both ; Driver program to test above function\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#include \\nvoid printDivisors ( int n ) { for ( int i = 1 ; i <= sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( n \\/ i == i ) printf ( \\\" % d ▁ \\\" , i ) ; printf ( \\\" % d ▁ % d ▁ \\\" , i , n \\/ i ) ; } } } int main ( ) { printf ( \\\" The ▁ divisors ▁ of ▁ 100 ▁ are : ▁ \\n \\\" ) ; printDivisors ( 100 ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Print characters and their frequencies in order of occurrence | Python3 implementation to print the characters and frequencies in order of its occurrence ; Store all characters and their frequencies in dictionary ; Print characters and their frequencies in same order of their appearance ; Print only if this character is not printed before . ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"def prCharWithFreq ( str ) :\\n\\td = { }\\n\\tfor i in str :\\n\\t\\tif i in d :\\n\\t\\t\\td [ i ] += 1\\n\\t\\telse :\\n\\t\\t\\td [ i ] = 1\\n\\tfor i in str :\\n\\t\\tif d [ i ] != 0 :\\n\\t\\t\\tprint ( \\\" { } { } \\\" . format ( i , d [ i ] ) , end = \\\" ▁ \\\" )\\n\\t\\t\\td [ i ] = 0\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tstr = \\\" geeksforgeeks \\\" ;\\n\\tprCharWithFreq ( str ) ;\\n'\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Program to find sum of harmonic series | C program to find sum of harmonic series ; Function to return sum of harmonic series ; Driver code\\\"\\nSolution in C:\",\"targets\":\"#include \\ndouble sum ( int n ) { double i , s = 0.0 ; for ( i = 1 ; i <= n ; i ++ ) s = s + 1 \\/ i ; return s ; } int main ( ) { int n = 5 ; printf ( \\\" Sum ▁ is ▁ % f \\\" , sum ( n ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Largest smaller number possible using only one swap operation | PHP program to find the largest smaller number by swapping one digit . Returns largest possible number with one swap such that the number is smaller than str . It is assumed that there are leading 0 s . ; Traverse from right until we find a digit which is greater than its next digit . For example , in 34125 , our index is 4. ; We can also use binary search here as digits after index are sorted in increasing order . Find the biggest digit in the right of arr [ index ] which is smaller than arr [ index ] ; If index is - 1 i . e . digits are in increasing order . ; Swap both values ; swap ( str [ index ] , str [ smallGreatDgt ] ) ; ; Driver code\\\"\\nSolution in php:\",\"targets\":\"< ? php function prevNum ( $ str ) { $ len = strlen ( $ str ) ; $ index = -1 ; for ( $ i = $ len - 2 ; $ i >= 0 ; $ i -- ) { if ( $ str [ $ i ] > $ str [ $ i + 1 ] ) { $ index = $ i ; break ; } } $ smallGreatDgt = -1 ; for ( $ i = $ len - 1 ; $ i > $ index ; $ i -- ) { if ( $ str [ $ i ] < $ str [ $ index ] ) { if ( $ smallGreatDgt == -1 ) $ smallGreatDgt = $ i ; else if ( $ str [ $ i ] >= $ str [ $ smallGreatDgt ] ) $ smallGreatDgt = $ i ; } } if ( $ index == -1 ) return \\\" - 1\\\" ; if ( $ smallGreatDgt != -1 ) { list ( $ str [ $ index ] , $ str [ $ smallGreatDgt ] ) = array ( $ str [ $ smallGreatDgt ] , $ str [ $ index ] ) ; return $ str ; } return \\\" - 1\\\" ; } $ str = \\\"34125\\\" ; echo prevNum ( $ str ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Modular multiplicative inverse from 1 to n | C ++ program to find modular inverse of all numbers from 1 to n using naive method ; A naive method to find modular multiplicative inverse of ' a ' under modulo ' prime ' ; Driver Program\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int modInverse ( int a , int prime ) { a = a % prime ; for ( int x = 1 ; x < prime ; x ++ ) if ( ( a * x ) % prime == 1 ) return x ; return -1 ; } void printModIverses ( int n , int prime ) { for ( int i = 1 ; i <= n ; i ++ ) cout << modInverse ( i , prime ) << \\\" ▁ \\\" ; } int main ( ) { int n = 10 , prime = 17 ; printModIverses ( n , prime ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Remove characters from a numeric string such that string becomes divisible by 8 | Java program to remove digits from a numeric string such that the number becomes divisible by 8 ; Function that return true if sub is a sub - sequence in s ; Function to return a multiple of 8 formed after removing 0 or more characters from the given string ; Iterate over all multiples of 8 ; If current multiple exists as a subsequence in the given string ; Driver Code\\\"\\nSolution in Java:\",\"targets\":\"class GFG { static boolean checkSub ( String sub , String s ) { int j = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) if ( sub . charAt ( j ) == s . charAt ( i ) ) j ++ ; return j == sub . length ( ) ; } static int getMultiple ( String s ) { for ( int i = 0 ; i < 1E3 ; i += 8 ) { if ( checkSub ( Integer . toString ( i ) , s ) ) return i ; } return - 1 ; } public static void main ( String [ ] args ) { String s = \\\"3454\\\" ; System . out . println ( getMultiple ( s ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Find all sides of a right angled triangle from given hypotenuse and area | Set 1 | C ++ program to get right angle triangle , given hypotenuse and area of triangle ; limit for float comparison ; Utility method to get area of right angle triangle , given base and hypotenuse ; Prints base and height of triangle using hypotenuse and area information ; maximum area will be obtained when base and height are equal ( = sqrt ( h * h \\/ 2 ) ) ; if given area itself is larger than maxArea then no solution is possible ; binary search for base ; get height by pythagorean rule ; Driver code to test above methods\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; #define eps 1e-6\\ndouble getArea ( double base , double hypotenuse ) { double height = sqrt ( hypotenuse * hypotenuse - base * base ) ; return 0.5 * base * height ; } void printRightAngleTriangle ( int hypotenuse , int area ) { int hsquare = hypotenuse * hypotenuse ; double sideForMaxArea = sqrt ( hsquare \\/ 2.0 ) ; double maxArea = getArea ( sideForMaxArea , hypotenuse ) ; if ( area > maxArea ) { cout << \\\" Not ▁ possiblen \\\" ; return ; } double low = 0.0 ; double high = sideForMaxArea ; double base ; while ( abs ( high - low ) > eps ) { base = ( low + high ) \\/ 2.0 ; if ( getArea ( base , hypotenuse ) >= area ) high = base ; else low = base ; } double height = sqrt ( hsquare - base * base ) ; cout << base << \\\" ▁ \\\" << height << endl ; } int main ( ) { int hypotenuse = 5 ; int area = 6 ; printRightAngleTriangle ( hypotenuse , area ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"Find a Fixed Point ( Value equal to index ) in a given array | C program to check fixed point in an array using binary search ; low + ( high - low ) \\/ 2 ; ; Return - 1 if there is no Fixed Point ; Driver program to check above functions\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint binarySearch ( int arr [ ] , int low , int high ) { if ( high >= low ) { int mid = ( low + high ) \\/ 2 ; if ( mid == arr [ mid ] ) return mid ; if ( mid > arr [ mid ] ) return binarySearch ( arr , ( mid + 1 ) , high ) ; else return binarySearch ( arr , low , ( mid - 1 ) ) ; } return -1 ; } int main ( ) { int arr [ 10 ] = { -10 , -1 , 0 , 3 , 10 , 11 , 30 , 50 , 100 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; printf ( \\\" Fixed ▁ Point ▁ is ▁ % d \\\" , binarySearch ( arr , 0 , n - 1 ) ) ; getchar ( ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Find the Longest Increasing Subsequence in Circular manner | Utility function to find LIS using Dynamic programming ; Initialize LIS values for all indexes ; Compute optimized LIS values in bottom up manner ; Set j on the basis of current window i . e . first element of the current window ; Pick maximum of all LIS values ; Function to find LIS in Circular manner ; Make a copy of given array by appending same array elements to itself ; Perform LIS for each window of size n ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function computeLIS ( $ circBuff , $ start , $ end , $ n ) { $ LIS = Array ( ) ; for ( $ i = $ start ; $ i < $ end ; $ i ++ ) $ LIS [ $ i ] = 1 ; for ( $ i = $ start + 1 ; $ i < $ end ; $ i ++ ) for ( $ j = $ start ; $ j < $ i ; $ j ++ ) if ( $ circBuff [ $ i ] > $ circBuff [ $ j ] && $ LIS [ $ i ] < $ LIS [ $ j ] + 1 ) $ LIS [ $ i ] = $ LIS [ $ j ] + 1 ; $ res = PHP_INT_MIN ; for ( $ i = $ start ; $ i < $ end ; $ i ++ ) $ res = max ( $ res , $ LIS [ $ i ] ) ; return $ res ; } function LICS ( $ arr , $ n ) { for ( $ i = 0 ; $ i < $ n ; $ i ++ ) $ circBuff [ $ i ] = $ arr [ $ i ] ; for ( $ i = $ n ; $ i < 2 * $ n ; $ i ++ ) $ circBuff [ $ i ] = $ arr [ $ i - $ n ] ; $ res = PHP_INT_MIN ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) $ res = max ( computeLIS ( $ circBuff , $ i , $ i + $ n , $ n ) , $ res ) ; return $ res ; } $ arr = array ( 1 , 4 , 6 , 2 , 3 ) ; $ n = sizeof ( $ arr ) ; echo \\\" Length ▁ of ▁ LICS ▁ is ▁ \\\" , LICS ( $ arr , $ n ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Probability of A winning the match when individual probabilities of hitting the target given | Function to return the probability of A winning ; p and q store the values of fractions a \\/ b and c \\/ d ; To store the winning probability of A ; Driver code\\\"\\nSolution in Python:\",\"targets\":\"def getProbability ( a , b , c , d ) :\\n\\tp = a \\/ b ;\\n\\tq = c \\/ d ;\\n\\tans = p * ( 1 \\/ ( 1 - ( 1 - q ) * ( 1 - p ) ) ) ;\\n\\treturn round ( ans , 5 ) ;\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\ta = 1 ; b = 2 ; c = 10 ; d = 11 ;\\n\\tprint ( getProbability ( a , b , c , d ) ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Number of ways to change the Array such that largest element is LCM of array | C ++ implementation to find the Number of ways to change the array such that maximum element of the array is the LCM of the array ; Modulo ; Fenwick tree to find number of indexes greater than x ; Function to compute x ^ y % MOD ; Loop to compute the x ^ y % MOD ; Function to update the binary indexed tree ; Function to find the prefix sum upto the current index ; Function to find the number of ways to change the array such that the LCM of array is maximum element of the array ; Updating BIT with the frequency of elements ; Maximum element in the array ; 1 is for every element is 1 in the array ; ; Vector for storing the factors ; finding factors of i ; Sorting in descending order ; for storing number of indexex greater than the i - 1 element ; Number of remaining factors ; Number of indexes in the array with element factor [ j ] and above ; Multiplying count with remFcators ^ ( indexes - prev ) ; Remove those counts which have lcm as i but i is not present ; Loop to find the count which have lcm as i but i is not present ; Adding cnt - toSubtract to answer ; Driver Code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; const int MOD = 1e9 + 7 ; const int N = 1e5 + 5 ; vector < int > BIT ( N , 0 ) ; int power ( int x , int y ) { if ( x == 0 ) return 0 ; int ans = 1 ; while ( y > 0 ) { if ( y & 1 ) ans = ( 1LL * ans * x ) % MOD ; x = ( 1LL * x * x ) % MOD ; y >>= 1 ; } return ans ; } void updateBIT ( int idx , int val ) { assert ( idx > 0 ) ; while ( idx < N ) { BIT [ idx ] += val ; idx += idx & - idx ; } } int queryBIT ( int idx ) { int ans = 0 ; while ( idx > 0 ) { ans += BIT [ idx ] ; idx -= idx & - idx ; } return ans ; } int numWays ( int arr [ ] , int n ) { int mx = 0 ; for ( int i = 0 ; i < n ; i ++ ) { updateBIT ( arr [ i ] , 1 ) ; mx = max ( mx , arr [ i ] ) ; } int ans = 1 ; for ( int i = 2 ; i <= mx ; i ++ ) { vector < int > factors ; for ( int j = 1 ; j * j <= i ; j ++ ) { if ( i % j == 0 ) { factors . push_back ( j ) ; if ( i \\/ j != j ) factors . push_back ( i \\/ j ) ; } } sort ( factors . rbegin ( ) , factors . rend ( ) ) ; int cnt = 1 ; int prev = 0 ; for ( int j = 0 ; j < factors . size ( ) ; j ++ ) { int remFactors = int ( factors . size ( ) ) - j ; int indexes = n - queryBIT ( factors [ j ] - 1 ) ; cnt = ( 1LL * cnt * power ( remFactors , indexes - prev ) ) % MOD ; prev = max ( prev , indexes ) ; } factors . erase ( factors . begin ( ) ) ; int toSubtract = 1 ; prev = 0 ; for ( int j = 0 ; j < factors . size ( ) ; j ++ ) { int remFactors = int ( factors . size ( ) ) - j ; int indexes = n - queryBIT ( factors [ j ] - 1 ) ; toSubtract = ( 1LL * toSubtract * power ( remFactors , indexes - prev ) ) ; prev = max ( prev , indexes ) ; } ans = ( 1LL * ans + cnt - toSubtract + MOD ) % MOD ; } return ans ; } int main ( ) { int arr [ ] = { 6 , 3 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; int ans = numWays ( arr , n ) ; cout << ans << endl ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Find all possible outcomes of a given expression | Utility function to evaluate a simple expression with one operator only . ; This function evaluates all possible values and returns a list of evaluated values . ; To store result ( all possible evaluations of given expression ' expr ' ) ; If there is only one character , it must be a digit ( or operand ) , return it . ; If there are only three characters , middle one must be operator and corner ones must be operand ; every i refers to an operator ; l refers to all the possible values in the left of operator ' expr [ i ] ' ; r refers to all the possible values in the right of operator ' expr [ i ] ' ; Take above evaluated all possible values in left side of ' i ' ; Take above evaluated all possible values in right side of ' i ' ; Calculate value for every pair and add the value to result . ; Driver program\\\"\\nSolution in Javascript:\",\"targets\":\"function eval ( a , op , b ) { if ( op == ' ' ) { return a + b ; } if ( op == ' ' ) { return a - b ; } if ( op == ' ' ) { return a * b ; } return Number . MAX_VALUE ; } function evaluateAll ( expr , low , high ) { let res = [ ] ; if ( low == high ) { res . push ( expr [ low ] - ' ' ) ; return res ; } if ( low == ( high - 2 ) ) { let num = eval ( expr [ low ] - ' ' , expr [ low + 1 ] , expr [ low + 2 ] - ' ' ) ; res . push ( num ) ; return res ; } for ( let i = low + 1 ; i <= high ; i += 2 ) { let l = evaluateAll ( expr , low , i - 1 ) ; let r = evaluateAll ( expr , i + 1 , high ) ; for ( let s1 = 0 ; s1 < l . length ; s1 ++ ) { for ( let s2 = 0 ; s2 < r . length ; s2 ++ ) { let val = eval ( l [ s1 ] , expr [ i ] , r [ s2 ] ) ; res . push ( val ) ; } } } return res ; } let expr = \\\" \\\" ; let len = expr . length ; let ans = evaluateAll ( expr , 0 , len - 1 ) ; for ( let i = 0 ; i < ans . length ; i ++ ) { document . write ( ans [ i ] + \\\" \\\" ) ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Largest odd divisor Game to check which player wins | Function to find the Largest Odd Divisior Game to check which player wins ; Check if n == 1 then player 2 will win ; Check if n == 2 or n is odd ; While n is greater than k and divisible by 2 keep incrementing tha val ; Loop to find greatest odd divisor ; Check if n is a power of 2 ; Check if cnt is not one then player 1 wins ; Driver Code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function findWinner ( n , k ) { let cnt = 0 ; if ( n == 1 ) document . write ( \\\" \\\" ) ; else if ( ( n & 1 ) != 0 n == 2 ) document . write ( \\\" \\\" ) ; else { let tmp = n ; let val = 1 ; while ( tmp > k && tmp % 2 == 0 ) { tmp \\/= 2 ; val *= 2 ; } for ( let i = 3 ; i <= Math . sqrt ( tmp ) ; i ++ ) { while ( tmp % i == 0 ) { cnt ++ ; tmp \\/= i ; } } if ( tmp > 1 ) cnt ++ ; if ( val == n ) document . write ( \\\" \\\" ) ; else if ( n \\/ tmp == 2 && cnt == 1 ) document . write ( \\\" \\\" ) ; else document . write ( \\\" \\\" ) ; } } let n = 1 , k = 1 ; findWinner ( n , k ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Largest divisor of a number not divisible by another given number | Python3 program to implement the above approach ; Function to find the largest number X such that it divides P but is not divisible by Q ; Stores the frequency count of of all Prime Factors ; Increment the frequency of the current prime factor ; If Q is a prime factor ; Stores the desired result ; Iterate through all divisors of Q ; Stores the frequency count of current prime divisor on dividing P ; Count the frequency of the current prime factor ; If cur is less than frequency then P is the final result ; Iterate to get temporary answer ; Update current answer ; Print the desired result ; Driver Code ; Given P and Q ; Function Call\\\"\\nSolution in Python:\",\"targets\":\"from collections import defaultdict\\ndef findTheGreatestX ( P , Q ) :\\n\\tdivisiors = defaultdict ( int )\\n\\ti = 2\\n\\twhile i * i <= Q :\\n\\t\\twhile ( Q % i == 0 and Q > 1 ) :\\n\\t\\t\\tQ \\/\\/= i\\n\\t\\t\\tdivisiors [ i ] += 1\\n\\t\\ti += 1\\n\\tif ( Q > 1 ) :\\n\\t\\tdivisiors [ Q ] += 1\\n\\tans = 0\\n\\tfor i in divisiors :\\n\\t\\tfrequency = divisiors [ i ]\\n\\t\\ttemp = P\\n\\t\\tcur = 0\\n\\t\\twhile ( temp % i == 0 ) :\\n\\t\\t\\ttemp \\/\\/= i\\n\\t\\t\\tcur += 1\\n\\t\\tif ( cur < frequency ) :\\n\\t\\t\\tans = P\\n\\t\\t\\tbreak\\n\\t\\ttemp = P\\n\\t\\tfor j in range ( cur , frequency - 1 , - 1 ) :\\n\\t\\t\\ttemp \\/\\/= i\\n\\t\\tans = max ( temp , ans )\\n\\tprint ( ans )\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tP = 10\\n\\tQ = 4\\n\\tfindTheGreatestX ( P , Q )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Make the list non | C # implementation of the approach ; Function to return the minimum element from the range [ prev , MAX ] such that it differs in at most 1 digit with cur ; To start with the value we have achieved in the last step ; Store the value with which the current will be compared ; Current value ; There are at most 4 digits ; If the current digit differs in both the numbers ; Eliminate last digits in both the numbers ; If the number of different digits is at most 1 ; If we can 't find any number for which the number of change is less than or equal to 1 then return -1 ; Function to get the non - decreasing list ; Creating a vector for the updated list ; Let 's assume that it is possible to make the list non-decreasing ; Element of the original array ; Can 't make the list non-decreasing ; If possible then print the list ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; using System . Collections . Generic ; class GFG { static int DIGITS = 4 , MIN = 1000 , MAX = 9999 ; static int getBest ( int prev , int cur ) { int maximum = Math . Max ( MIN , prev ) ; for ( int i = maximum ; i <= MAX ; i ++ ) { int cnt = 0 ; int a = i ; int b = cur ; for ( int k = 0 ; k < DIGITS ; k ++ ) { if ( a % 10 != b % 10 ) cnt += 1 ; a \\/= 10 ; b \\/= 10 ; } if ( cnt <= 1 ) return i ; } return - 1 ; } static void getList ( int [ ] arr , int n ) { List < int > myList = new List < int > ( ) ; int i , cur ; bool possible = true ; myList . Add ( 0 ) ; for ( i = 0 ; i < n ; i ++ ) { cur = arr [ i ] ; myList . Add ( getBest ( myList [ myList . Count - 1 ] , cur ) ) ; if ( myList [ myList . Count - 1 ] == - 1 ) { possible = false ; break ; } } if ( possible ) { for ( i = 1 ; i < myList . Count ; i ++ ) Console . Write ( myList [ i ] + \\\" ▁ \\\" ) ; } else Console . Write ( \\\" - 1\\\" ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1095 , 1094 , 1095 } ; int n = arr . Length ; getList ( arr , n ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Linear Search | Java code for linearly searching x in arr [ ] . If x is present then return its location , otherwise return - 1 ; Driver code ; Function call\\\"\\nSolution in Java:\",\"targets\":\"class GFG { public static int search ( int arr [ ] , int x ) { int n = arr . length ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == x ) return i ; } return - 1 ; } public static void main ( String args [ ] ) { int arr [ ] = { 2 , 3 , 4 , 10 , 40 } ; int x = 10 ; int result = search ( arr , x ) ; if ( result == - 1 ) System . out . print ( \\\" Element ▁ is ▁ not ▁ present ▁ in ▁ array \\\" ) ; else System . out . print ( \\\" Element ▁ is ▁ present ▁ at ▁ index ▁ \\\" + result ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Minimum multiplications with { 2 , 3 , 7 } to make two numbers equal | Function to find powers of 2 , 3 and 7 in x ; To keep count of each divisor ; To store the result ; Count powers of 2 in x ; Count powers of 3 in x ; Count powers of 7 in x ; Remaining number which is not divisible by 2 , 3 or 7 ; Function to return the minimum number of given operations required to make a and b equal ; a = x * 2 ^ a1 * 3 ^ a2 * 7 ^ a3 va [ 0 ] = a1 va [ 1 ] = a2 va [ 2 ] = a3 va [ 3 ] = x ; Similarly for b ; If a and b cannot be made equal with the given operation . Note that va [ 3 ] and vb [ 3 ] contain remaining numbers after repeated divisions with 2 , 3 and 7. If remaining numbers are not same then we cannot make them equal . ; Minimum number of operations required ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function Divisors ( $ x ) { $ c = 0 ; $ v = array ( ) ; while ( $ x % 2 == 0 ) { $ c ++ ; $ x = floor ( $ x \\/ 2 ) ; } array_push ( $ v , $ c ) ; $ c = 0 ; while ( $ x % 3 == 0 ) { $ c ++ ; $ x = floor ( $ x \\/ 3 ) ; } array_push ( $ v , $ c ) ; $ c = 0 ; while ( $ x % 7 == 0 ) { $ c ++ ; $ x = floor ( $ x \\/ 7 ) ; } array_push ( $ v , $ c ) ; array_push ( $ v , $ x ) ; return $ v ; } function MinOperations ( $ a , $ b ) { $ va = Divisors ( $ a ) ; $ vb = Divisors ( $ b ) ; if ( $ va [ 3 ] != $ vb [ 3 ] ) return -1 ; $ minOperations = abs ( $ va [ 0 ] - $ vb [ 0 ] ) + abs ( $ va [ 1 ] - $ vb [ 1 ] ) + abs ( $ va [ 2 ] - $ vb [ 2 ] ) ; return $ minOperations ; } $ a = 14 ; $ b = 28 ; echo MinOperations ( $ a , $ b ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Sum of numbers from 1 to N which are divisible by 3 or 4 | Function to calculate the sum of numbers divisible by 3 or 4 ;\\\"\\nSolution in Python:\",\"targets\":\"def sum ( N ) :\\n\\tglobal S1 , S2 , S3\\n\\tS1 = ( ( ( N \\/\\/ 3 ) ) * ( 2 * 3 + ( N \\/\\/ 3 - 1 ) * 3 ) \\/\\/ 2 )\\n\\tS2 = ( ( ( N \\/\\/ 4 ) ) * ( 2 * 4 + ( N \\/\\/ 4 - 1 ) * 4 ) \\/\\/ 2 )\\n\\tS3 = ( ( ( N \\/\\/ 12 ) ) * ( 2 * 12 + ( N \\/\\/ 12 - 1 ) * 12 ) \\/\\/ 2 )\\n\\treturn int ( S1 + S2 - S3 )\\n\\/ * Driver code * \\/\\nif __name__ == ' _ _ main _ _ ' :\\n\\tN = 12\\n\\tprint ( sum ( N ) )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"Legendre 's formula (Given p and n, find the largest x such that p^x divides n!) | C program to find largest x such that p * x divides n ! ; Returns largest power of p that divides n ! ; Initialize result ; Calculate x = n \\/ p + n \\/ ( p ^ 2 ) + n \\/ ( p ^ 3 ) + ... . ; Driver program\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint largestPower ( int n , int p ) { int x = 0 ; while ( n ) { n \\/= p ; x += n ; } return x ; } int main ( ) { int n = 10 , p = 3 ; printf ( \\\" The ▁ largest ▁ power ▁ of ▁ % d ▁ that ▁ divides ▁ % d ! ▁ is ▁ % d \\n \\\" , p , n , largestPower ( n , p ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Segregate Prime and Non | C # program for the above approach ; Function to generate prime numbers using Sieve of Eratosthenes ; If prime [ p ] is unchanged , then it is a prime ; Update all multiples of p ; Function to segregate the primes and non - primes ; Generate all primes till 10 ^ ; Initialize left and right ; Traverse the array ; Increment left while array element at left is prime ; Decrement right while array element at right is non - prime ; If left < right , then swap arr [ left ] and arr [ right ] ; Swap arr [ left ] and arr [ right ] ; Print segregated array ; Driver code ; Function Call\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { public static void SieveOfEratosthenes ( bool [ ] prime , int n ) { for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= n ; i += p ) prime [ i ] = false ; } } } public static void segregatePrimeNonPrime ( bool [ ] prime , int [ ] arr , int N ) { SieveOfEratosthenes ( prime , 10000000 ) ; int left = 0 , right = N - 1 ; while ( left < right ) { while ( prime [ arr [ left ] ] ) left ++ ; while ( ! prime [ arr [ right ] ] ) right -- ; if ( left < right ) { int temp = arr [ left ] ; arr [ left ] = arr [ right ] ; arr [ right ] = temp ; left ++ ; right -- ; } } for ( int i = 0 ; i < N ; i ++ ) Console . Write ( arr [ i ] + \\\" ▁ \\\" ) ; } public static void Main ( String [ ] args ) { bool [ ] prime = new bool [ 10000001 ] ; for ( int i = 0 ; i < prime . Length ; i ++ ) prime [ i ] = true ; int [ ] arr = { 2 , 3 , 4 , 6 , 7 , 8 , 9 , 10 } ; int N = arr . Length ; segregatePrimeNonPrime ( prime , arr , N ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Count of a , b & c after n seconds for given reproduction rate | Function to prvar the count of a , b and c after n seconds ; Number of multiples of 60 below n ; Multiple of 60 nearest to n ; Change all a to b ; Change all b to c ; Change each c to two a ; Print the updated values of a , b and c ; Driver code\\\"\\nSolution in Javascript:\",\"targets\":\"function findCount ( n ) { var a = 1 , b = 0 , c = 0 ; var x = parseInt ( n \\/ 60 ) ; a = Math . pow ( 32 , x ) ; x = 60 * x ; for ( i = x + 1 ; i <= n ; i ++ ) { if ( i % 2 == 0 ) { b += a ; a = 0 ; } if ( i % 5 == 0 ) { c += b ; b = 0 ; } if ( i % 12 == 0 ) { a += ( 2 * c ) ; c = 0 ; } } document . write ( \\\" \\\" + a + \\\" \\\" + b + \\\" \\\" + c ) ; } var n = 72 ; findCount ( n ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Minimum cost to generate any permutation of the given string | Function that returns true if the current bit is set ; Function to find the minimum cost to form any permutation of string s ; Base Case ; Return the precomputed state ; Iterate over the string and check all possible characters available for current position ; Check if character can be placed at current position ; As there is no previous character so the cost for 1 st character is 0 ; Find the cost of current character and move to next position ; Store the answer for each current state ; Function that generates any permutation of the given string with minimum cost ; Initialize dp table ; Set all the bits of the current character id ; Minimum cost of generating the permutation ; Driver Code ; Function Call\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function check ( mask , i ) { var c = ( mask & ( 1 << i ) ) ; return c != 0 ; } function solve ( a , s , n , prev , mask , dp ) { if ( mask == 0 ) return 0 ; if ( dp [ mask ] [ prev + 1 ] != - 1 ) return dp [ mask ] [ prev + 1 ] ; var ans = 10000 ; for ( var i = 0 ; i < s . length ; i ++ ) { var id = s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ; if ( check ( mask , id ) ) { if ( prev == - 1 ) { ans = Math . min ( ans , solve ( a , s , n , id , mask ^ ( 1 << id ) , dp ) ) ; } else { ans = Math . min ( ans , a [ prev ] [ id ] + solve ( a , s , n , id , mask ^ ( 1 << id ) , dp ) ) ; } } } dp [ mask ] [ prev + 1 ] = ans ; return ans ; } function generatePermutation ( mask , n , a , s ) { var dp = Array . from ( Array ( ( 1 << n ) + 5 ) , ( ) => Array ( n + 5 ) . fill ( - 1 ) ) ; for ( var i = 0 ; i < s . length ; i ++ ) { var id = s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ; mask |= ( 1 << id ) ; } document . write ( solve ( a , s , n , - 1 , mask , dp ) + \\\" \\\" ) ; } var N = 5 ; var str = \\\" \\\" ; var mat = [ [ 0 , 5 , 1 , 5 , 3 ] , [ 4 , 0 , 9 , 4 , 2 ] , [ 7 , 9 , 0 , 10 , 7 ] , [ 1 , 2 , 8 , 0 , 2 ] , [ 3 , 9 , 7 , 7 , 0 ] ] ; generatePermutation ( 0 , N , mat , str ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Tetranacci Numbers | Function to return the N - th tetranacci number ; base cases ; base cases ; base cases ; function to print the nth tetranacci number ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function printTetraRec ( $ n ) { if ( $ n == 0 ) return 0 ; if ( $ n == 1 $ n == 2 ) return 1 ; if ( $ n == 3 ) return 2 ; else return printTetraRec ( $ n - 1 ) + printTetraRec ( $ n - 2 ) + printTetraRec ( $ n - 3 ) + printTetraRec ( $ n - 4 ) ; } function printTetra ( $ n ) { echo printTetraRec ( $ n ) . \\\" \\\" ; } $ n = 10 ; printTetra ( $ n ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Area of a circle inscribed in a rectangle which is inscribed in a semicircle | C # Program to find the area of the circle inscribed within the rectangle which in turn is inscribed in a semicircle ; Function to find the area of the circle ; radius cannot be negative ; area of the circle ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static float area ( float r ) { if ( r < 0 ) return - 1 ; float area = ( float ) ( 3.14 * Math . Pow ( r \\/ ( 2 * Math . Sqrt ( 2 ) ) , 2 ) ) ; return area ; } static public void Main ( String [ ] args ) { float a = 5 ; Console . WriteLine ( area ( a ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Palindromic divisors of a number | Function to check is num is palindromic or not ; Convert n to string str ; Starting and ending index of string str ; If char at s and e are not equals then return false ; Function to find palindromic divisors ; To sore the palindromic divisors of number n ; If n is divisible by i ; Check if number is a perfect square ; Check divisor is palindromic , then store it ; Check if divisors are palindrome ; Check if n \\/ divisors is palindromic or not ; Print all palindromic divisors in sorted order ; Driver code ; Function call to find all palindromic divisors\\\"\\nSolution in Javascript:\",\"targets\":\"function isPalindrome ( n ) { var str = ( n . toString ( ) ) ; var s = 0 , e = str . length - 1 ; while ( s < e ) { if ( str [ s ] != str [ e ] ) { return false ; } s ++ ; e -- ; } return true ; } function palindromicDivisors ( n ) { var PalindromDivisors = [ ] ; for ( var i = 1 ; i <= parseInt ( Math . sqrt ( n ) ) ; i ++ ) { if ( n % i == 0 ) { if ( n \\/ i == i ) { if ( isPalindrome ( i ) ) { PalindromDivisors . push ( i ) ; } } else { if ( isPalindrome ( i ) ) { PalindromDivisors . push ( i ) ; } if ( isPalindrome ( n \\/ i ) ) { PalindromDivisors . push ( n \\/ i ) ; } } } } PalindromDivisors . sort ( ( a , b ) => a - b ) for ( var i = 0 ; i < PalindromDivisors . length ; i ++ ) { document . write ( PalindromDivisors [ i ] + \\\" \\\" ) ; } } var n = 66 ; palindromicDivisors ( n ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Rearrange a given linked list in | C ++ code to rearrange linked list in place ; function for rearranging a linked list with high and low value . ; Base case . ; two pointer variable . ; swap function for swapping data . ; swap function for swapping data . ; function to insert a node in the linked list at the beginning . ; function to display node of linked list . ; driver code ; let create a linked list . 9 -> 6 -> 8 -> 3 -> 7\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; struct node { int data ; struct node * next ; } ; typedef struct node Node ; void rearrange ( Node * head ) { if ( head == NULL ) return ; Node * prev = head , * curr = head -> next ; while ( curr ) { if ( prev -> data > curr -> data ) swap ( prev -> data , curr -> data ) ; if ( curr -> next && curr -> next -> data > curr -> data ) swap ( curr -> next -> data , curr -> data ) ; prev = curr -> next ; if ( ! curr -> next ) break ; curr = curr -> next -> next ; } } void push ( Node * * head , int k ) { Node * tem = ( Node * ) malloc ( sizeof ( Node ) ) ; tem -> data = k ; tem -> next = * head ; * head = tem ; } void display ( Node * head ) { Node * curr = head ; while ( curr != NULL ) { printf ( \\\" % d ▁ \\\" , curr -> data ) ; curr = curr -> next ; } } int main ( ) { Node * head = NULL ; push ( & head , 7 ) ; push ( & head , 3 ) ; push ( & head , 8 ) ; push ( & head , 6 ) ; push ( & head , 9 ) ; rearrange ( head ) ; display ( head ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"How to print maximum number of A 's using given four keys | A recursive C program to print maximum number of A 's using following four keys ; A recursive function that returns the optimal length string for N keystrokes ; The optimal string length is N when N is smaller than 7 ; Initialize result ; TRY ALL POSSIBLE BREAK - POINTS For any keystroke N , we need to loop from N - 3 keystrokes back to 1 keystroke to find a breakpoint ' b ' after which we will have Ctrl - A , Ctrl - C and then only Ctrl - V all the way . ; If the breakpoint is s at b 'th keystroke then the optimal string would have length (n-b-1)*screen[b-1]; ; Driver program ; for the rest of the array we will rely on the previous entries to compute new ones\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint findoptimal ( int N ) { if ( N <= 6 ) return N ; int max = 0 ; int b ; for ( b = N - 3 ; b >= 1 ; b -- ) { int curr = ( N - b - 1 ) * findoptimal ( b ) ; if ( curr > max ) max = curr ; } return max ; } int main ( ) { int N ; for ( N = 1 ; N <= 20 ; N ++ ) printf ( \\\" Maximum ▁ Number ▁ of ▁ A ' s ▁ with ▁ % d ▁ keystrokes ▁ is ▁ % d \\n \\\" , N , findoptimal ( N ) ) ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Check if a string can be converted to another by swapping of adjacent characters of given type | C # program for the above approach ; Function to check if it is possible to transform start to end ; Check the sequence of A , B in both Strings str1 and str2 ; If both the Strings are not equal ; Traverse the Strings ; Check for indexes of A and B ; Driver Code ; Function call\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static bool canTransform ( string str1 , string str2 ) { string s1 = \\\" \\\" ; string s2 = \\\" \\\" ; foreach ( char c in str1 . ToCharArray ( ) ) { if ( c != ' C ' ) { s1 += c ; } } foreach ( char c in str2 . ToCharArray ( ) ) { if ( c != ' C ' ) { s2 += c ; } } if ( s1 != s2 ) return false ; int i = 0 ; int j = 0 ; int n = str1 . Length ; while ( i < n && j < n ) { if ( str1 [ i ] == ' C ' ) { i ++ ; } else if ( str2 [ j ] == ' C ' ) { j ++ ; } else { if ( ( str1 [ i ] == ' A ' && i < j ) || ( str1 [ i ] == ' B ' && i > j ) ) { return false ; } i ++ ; j ++ ; } } return true ; } public static void Main ( string [ ] args ) { string str1 = \\\" BCCABCBCA \\\" ; string str2 = \\\" CBACCBBAC \\\" ; if ( canTransform ( str1 , str2 ) ) { Console . Write ( \\\" Yes \\\" ) ; } else { Console . Write ( \\\" No \\\" ) ; } } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Minimum number of deletions and insertions to transform one string into another | Returns length of length common subsequence for str1 [ 0. . m - 1 ] , str2 [ 0. . n - 1 ] ; Following steps build L [ m + 1 ] [ n + 1 ] in bottom up fashion . Note that L [ i ] [ j ] contains length of LCS of str1 [ 0. . i - 1 ] and str2 [ 0. . j - 1 ] ; L [ m ] [ n ] contains length of LCS for X [ 0. . n - 1 ] and Y [ 0. . m - 1 ] ; function to find minimum number of deletions and insertions ; Driver code ; Function Call\\\"\\nSolution in Javascript:\",\"targets\":\"function lcs ( str1 , str2 , m , n ) { let L = new Array ( m + 1 ) ; let i , j ; for ( i = 0 ; i <= m ; i ++ ) { L [ i ] = new Array ( n + 1 ) ; for ( j = 0 ; j <= n ; j ++ ) { L [ i ] [ j ] = 0 ; } } for ( i = 0 ; i <= m ; i ++ ) { for ( j = 0 ; j <= n ; j ++ ) { if ( i == 0 j == 0 ) L [ i ] [ j ] = 0 ; else if ( str1 [ i - 1 ] == str2 [ j - 1 ] ) L [ i ] [ j ] = L [ i - 1 ] [ j - 1 ] + 1 ; else L [ i ] [ j ] = Math . max ( L [ i - 1 ] [ j ] , L [ i ] [ j - 1 ] ) ; } } return L [ m ] [ n ] ; } function printMinDelAndInsert ( str1 , str2 ) { let m = str1 . length ; let n = str2 . length ; let len = lcs ( str1 , str2 , m , n ) ; document . write ( \\\" \\\" + \\\" \\\" ) ; document . write ( ( m - len ) + \\\" \\\" ) ; document . write ( \\\" \\\" + \\\" \\\" ) ; document . write ( ( n - len ) + \\\" \\\" ) ; } let str1 = \\\" \\\" ; let str2 = \\\" \\\" ; printMinDelAndInsert ( str1 , str2 ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Find the number of cells in the table contains X | C # program to find number of cells in the table contains X ; Function to find number of cells in the table contains X ; Driver code ; Function call\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static int Cells ( int n , int x ) { int ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) if ( x % i == 0 && x \\/ i <= n ) ans ++ ; return ans ; } public static void Main ( ) { int n = 6 , x = 12 ; Console . WriteLine ( Cells ( n , x ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Number of ways to arrange a word such that no vowels occur together | Function to check if a character is vowel or consonent ; Function to calculate factorial of a number ; Calculating no of ways for arranging vowels ; Iterate the map and count the number of vowels and calculate no of ways to arrange vowels ; Calculating no of ways to arrange the given word such that all vowels come together ; Calculate no of ways to arrange vowels ; To store denominator of fraction ; Count of consonents ; Calculate the number of ways to arrange the word such that all vowels come together ; To calculate total number of permutations ; To store length of the given word ; Denominator of fraction ; Return total number of permutations of the given word ; Function to calculate number of permutations such that no vowels come together ; To store frequency of character ; Count frequency of all characters ; Calculate total number of permutations ; Calculate total number of permutations such that all vowels come together ; Subtract vwl_tgthr from total to get the result ; Return the result ; Driver code\\\"\\nSolution in Javascript:\",\"targets\":\"function isVowel ( ch ) { if ( ch == ' ' ch == ' ' ch == ' ' ch == ' ' ch == ' ' ) return true ; else return false ; } function fact ( n ) { if ( n < 2 ) { return 1 ; } return n * fact ( n - 1 ) ; } function only_vowels ( freq ) { let denom = 1 ; let cnt_vwl = 0 ; for ( let [ key , value ] of freq . entries ( ) ) { if ( isVowel ( key ) ) { denom *= fact ( value ) ; cnt_vwl += value ; } } return Math . floor ( fact ( cnt_vwl ) \\/ denom ) ; } function all_vowels_together ( freq ) { let vow = only_vowels ( freq ) ; let denom = 1 ; let cnt_cnst = 0 ; for ( let [ key , value ] of freq . entries ( ) ) { if ( ! isVowel ( key ) ) { denom *= fact ( value ) ; cnt_cnst += value ; } } let ans = Math . floor ( fact ( cnt_cnst + 1 ) \\/ denom ) ; return ( ans * vow ) ; } function total_permutations ( freq ) { let cnt = 0 ; let denom = 1 ; for ( let [ key , value ] of freq . entries ( ) ) { denom *= fact ( value ) ; cnt += value ; } return Math . floor ( fact ( cnt ) \\/ denom ) ; } function no_vowels_together ( word ) { let freq = new Map ( ) ; for ( let i = 0 ; i < word . length ; i ++ ) { let ch = word [ i ] . toLowerCase ( ) ; if ( freq . has ( ch ) ) { freq . set ( ch , freq . get ( ch ) + 1 ) ; } else { freq . set ( ch , 1 ) ; } } let total = total_permutations ( freq ) ; let vwl_tgthr = all_vowels_together ( freq ) ; let res = total - vwl_tgthr ; return res ; } let word = \\\" \\\" ; let ans = no_vowels_together ( word ) ; document . write ( ans + \\\" \\\" ) ; word = \\\" \\\" ; ans = no_vowels_together ( word ) ; document . write ( ans + \\\" \\\" ) ; word = \\\" \\\" ; ans = no_vowels_together ( word ) ; document . write ( ans + \\\" \\\" ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"Program for addition of two matrices | ; This function adds A [ ] [ ] and B [ ] [ ] , and stores the result in C [ ] [ ] ; Driver code\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#define N 4\\nvoid add ( int A [ ] [ N ] , int B [ ] [ N ] , int C [ ] [ N ] ) { int i , j ; for ( i = 0 ; i < N ; i ++ ) for ( j = 0 ; j < N ; j ++ ) C [ i ] [ j ] = A [ i ] [ j ] + B [ i ] [ j ] ; } int main ( ) { int A [ N ] [ N ] = { { 1 , 1 , 1 , 1 } , { 2 , 2 , 2 , 2 } , { 3 , 3 , 3 , 3 } , { 4 , 4 , 4 , 4 } } ; int B [ N ] [ N ] = { { 1 , 1 , 1 , 1 } , { 2 , 2 , 2 , 2 } , { 3 , 3 , 3 , 3 } , { 4 , 4 , 4 , 4 } } ; int C [ N ] [ N ] ; int i , j ; add ( A , B , C ) ; printf ( \\\" Result ▁ matrix ▁ is ▁ \\n \\\" ) ; for ( i = 0 ; i < N ; i ++ ) { for ( j = 0 ; j < N ; j ++ ) printf ( \\\" % d ▁ \\\" , C [ i ] [ j ] ) ; printf ( \\\" \\n \\\" ) ; } return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Maximize the sum of differences of consecutive elements after removing exactly K elements | C ++ implementation of the approach ; Function to return the maximized sum ; Remove any k internal elements ; Driver code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int findSum ( int * arr , int n , int k ) { if ( k <= n - 2 ) return ( arr [ n - 1 ] - arr [ 0 ] ) ; return 0 ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int n = sizeof ( arr ) \\/ sizeof ( int ) ; int k = 1 ; cout << findSum ( arr , n , k ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Gould 's Sequence | Function to generate gould 's Sequence ; loop to generate each row of pascal 's Triangle up to nth row ; Loop to generate each element of ith row ; if c is odd increment count ; print count of odd elements ; Get n ; Function call\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function gouldSequence ( $ n ) { for ( $ row_num = 1 ; $ row_num <= $ n ; $ row_num ++ ) { $ count = 1 ; $ c = 1 ; for ( $ i = 1 ; $ i <= $ row_num ; $ i ++ ) { $ c = $ c * ( $ row_num - $ i ) \\/ $ i ; if ( $ c % 2 == 1 ) $ count ++ ; } echo $ count , \\\" \\\" ; } } $ n = 16 ; gouldSequence ( $ n ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Program to calculate angle between two N | Function to find the magnitude of the given vector ; Stores the final magnitude ; Traverse the array ; Return square root of magnitude ; Function to find the dot product of two vectors ; Stores dot product ; Traverse the array ; Return the product ; Stores dot product of two vectors ; Stores magnitude of vector A ; Stores magnitude of vector B ; Stores angle between given vectors ; Print the angle ; Given magnitude arrays ; Size of the array ; Function call to find the angle between two vectors\\\"\\nSolution in Javascript:\",\"targets\":\"function magnitude ( arr , N ) { var magnitude = 0 ; for ( var i = 0 ; i < N ; i ++ ) magnitude += arr [ i ] * arr [ i ] ; return Math . sqrt ( magnitude ) ; } function dotProduct ( arr , brr , N ) { var product = 0 ; for ( var i = 0 ; i < N ; i ++ ) product = product + arr [ i ] * brr [ i ] ; return product ; } function angleBetweenVectors ( arr , brr , N ) { var dotProductOfVectors = dotProduct ( arr , brr , N ) ; var magnitudeOfA = magnitude ( arr , N ) ; var magnitudeOfB = magnitude ( brr , N ) ; var angle = dotProductOfVectors \\/ ( magnitudeOfA * magnitudeOfB ) ; document . write ( angle . toFixed ( 6 ) ) ; } var arr = [ - 0.5 , - 2 , 1 ] ; var brr = [ - 1 , - 1 , 0.3 ] ; var N = arr . length ; angleBetweenVectors ( arr , brr , N ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Sum of kth powers of first n natural numbers | C ++ program to find sum pf k - th powers of first n natural numbers . ; A global array to store factorials ; Function to calculate the factorials of all the numbers upto k ; Function to return the binomial coefficient ; nCr = ( n ! * ( n - r ) ! ) \\/ r ! ; Function to return the sum of kth powers of n natural numbers ; When j is unity ; Calculating sum ( n ^ 1 ) of unity powers of n ; storing sum ( n ^ 1 ) for sum ( n ^ 2 ) ; If k = 1 then temp is the result ; For finding sum ( n ^ k ) removing 1 and n * kCk from ( n + 1 ) ^ k ; Removing all kC2 * sum ( n ^ ( k - 2 ) ) + ... + kCk - 1 * ( sum ( n ^ ( k - ( k - 1 ) ) ; Storing the result for next sum of next powers of k ; Driver code\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; const int MAX_K = 15 ; long long unsigned int fac [ MAX_K ] ; void factorial ( int k ) { fac [ 0 ] = 1 ; for ( int i = 1 ; i <= k + 1 ; i ++ ) { fac [ i ] = ( i * fac [ i - 1 ] ) ; } } long long unsigned int bin ( int a , int b ) { long long unsigned int ans = ( ( fac [ a ] ) \\/ ( fac [ a - b ] * fac [ b ] ) ) ; return ans ; } long int sumofn ( int n , int k ) { int p = 0 ; long long unsigned int num1 , temp , arr [ 1000 ] ; for ( int j = 1 ; j <= k ; j ++ ) { if ( j == 1 ) { num1 = ( n * ( n + 1 ) ) \\/ 2 ; arr [ p ++ ] = num1 ; temp = num1 ; } else { temp = ( pow ( n + 1 , j + 1 ) - 1 - n ) ; for ( int s = 1 ; s < j ; s ++ ) { temp = temp - ( arr [ j - s - 1 ] * bin ( j + 1 , s + 1 ) ) ; } temp = temp \\/ ( j + 1 ) ; arr [ p ++ ] = temp ; } } temp = arr [ p - 1 ] ; return temp ; } int main ( ) { int n = 5 , k = 2 ; factorial ( k ) ; cout << sumofn ( n , k ) << \\\" \\n \\\" ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Given an array arr [ ] , find the maximum j | For a given array arr [ ] , returns the maximum j a i such that arr [ j ] > arr [ i ] ; driver code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def maxIndexDiff ( arr , n ) :\\n\\tmaxDiff = - 1\\n\\tfor i in range ( 0 , n ) :\\n\\t\\tj = n - 1\\n\\t\\twhile ( j > i ) :\\n\\t\\t\\tif arr [ j ] > arr [ i ] and maxDiff < ( j - i ) :\\n\\t\\t\\t\\tmaxDiff = j - i\\n\\t\\t\\tj -= 1\\n\\treturn maxDiff\\narr = [ 9 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 18 , 0 ]\\nn = len ( arr )\\nmaxDiff = maxIndexDiff ( arr , n )\\nprint ( maxDiff )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Find Corners of Rectangle using mid points | Java program to find corner points of a rectangle using given length and middle points . ; Structure to represent a co - ordinate point ; This function receives two points and length of the side of rectangle and prints the 4 corner points of the rectangle ; horizontal rectangle ; vertical rectangle ; slanted rectangle ; calculate slope of the side ; calculate displacements along axes ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"class GFG { static class Point { float x , y ; Point ( ) { x = y = 0 ; } Point ( float a , float b ) { x = a ; y = b ; } } ; static void printCorners ( Point p , Point q , float l ) { Point a = new Point ( ) , b = new Point ( ) , c = new Point ( ) , d = new Point ( ) ; if ( p . x == q . x ) { a . x = ( float ) ( p . x - ( l \\/ 2.0 ) ) ; a . y = p . y ; d . x = ( float ) ( p . x + ( l \\/ 2.0 ) ) ; d . y = p . y ; b . x = ( float ) ( q . x - ( l \\/ 2.0 ) ) ; b . y = q . y ; c . x = ( float ) ( q . x + ( l \\/ 2.0 ) ) ; c . y = q . y ; } else if ( p . y == q . y ) { a . y = ( float ) ( p . y - ( l \\/ 2.0 ) ) ; a . x = p . x ; d . y = ( float ) ( p . y + ( l \\/ 2.0 ) ) ; d . x = p . x ; b . y = ( float ) ( q . y - ( l \\/ 2.0 ) ) ; b . x = q . x ; c . y = ( float ) ( q . y + ( l \\/ 2.0 ) ) ; c . x = q . x ; } else { float m = ( p . x - q . x ) \\/ ( q . y - p . y ) ; float dx = ( float ) ( ( l \\/ Math . sqrt ( 1 + ( m * m ) ) ) * 0.5 ) ; float dy = m * dx ; a . x = p . x - dx ; a . y = p . y - dy ; d . x = p . x + dx ; d . y = p . y + dy ; b . x = q . x - dx ; b . y = q . y - dy ; c . x = q . x + dx ; c . y = q . y + dy ; } System . out . print ( ( int ) a . x + \\\" , ▁ \\\" + ( int ) a . y + \\\"\\n\\\" + ( int ) b . x + \\\" , ▁ \\\" + ( int ) b . y + \\\"\\n\\\" + ( int ) c . x + \\\" , ▁ \\\" + ( int ) c . y + \\\"\\n\\\" + ( int ) d . x + \\\" , ▁ \\\" + ( int ) d . y + \\\"\\n\\\"); } public static void main ( String [ ] args ) { Point p1 = new Point ( 1 , 0 ) , q1 = new Point ( 1 , 2 ) ; printCorners ( p1 , q1 , 2 ) ; Point p = new Point ( 1 , 1 ) , q = new Point ( - 1 , - 1 ) ; printCorners ( p , q , ( float ) ( 2 * Math . sqrt ( 2 ) ) ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Print all numbers whose set of prime factors is a subset of the set of the prime factors of X | C # program to implement the above approach ; Function to print all the numbers ; Iterate for every element in the array ; Find the gcd ; Iterate till gcd is 1 of number and x ; Divide the number by gcd ; Find the new gcdg ; If the number is 1 at the end then print the number ; If no numbers have been there ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static void printNumbers ( int [ ] a , int n , int x ) { bool flag = false ; for ( int i = 0 ; i < n ; i ++ ) { int num = a [ i ] ; int g = __gcd ( num , x ) ; while ( g != 1 ) { num \\/= g ; g = __gcd ( num , x ) ; } if ( num == 1 ) { flag = true ; Console . Write ( a [ i ] + \\\" ▁ \\\" ) ; } } if ( ! flag ) Console . WriteLine ( \\\" There ▁ are ▁ no ▁ such ▁ numbers \\\" ) ; } static int __gcd ( int a , int b ) { if ( b == 0 ) return a ; return __gcd ( b , a % b ) ; } public static void Main ( String [ ] args ) { int x = 60 ; int [ ] a = { 2 , 5 , 10 , 7 , 17 } ; int n = a . Length ; printNumbers ( a , n , x ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"Add two numbers without using arithmetic operators | C Program to add two numbers without using arithmetic operator ; Iterate till there is no carry ; carry now contains common set bits of x and y ; Sum of bits of x and y where at least one of the bits is not set ; Carry is shifted by one so that adding it to x gives the required sum ; Driver Code\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint Add ( int x , int y ) { while ( y != 0 ) { int carry = x & y ; x = x ^ y ; y = carry << 1 ; } return x ; } int main ( ) { printf ( \\\" % d \\\" , Add ( 15 , 32 ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"Longest Arithmetic Progression | DP | The function returns true if there exist three elements in AP Assumption : set [ 0. . n - 1 ] is sorted . The code strictly implements the algorithm provided in the reference . ; One by fix every element as middle element ; Initialize i and k for the current j ; Find if there exist i and k that form AP with j as middle element\\nHow can the above be solved in C?\",\"targets\":\"bool arithmeticThree ( int set [ ] , int n ) { for ( int j = 1 ; j < n - 1 ; j ++ ) { int i = j - 1 , k = j + 1 ; while ( i >= 0 && k <= n - 1 ) { if ( set [ i ] + set [ k ] == 2 * set [ j ] ) return true ; ( set [ i ] + set [ k ] < 2 * set [ j ] ) ? k ++ : i -- ; } } return false ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Find all factors of a natural number | Set 1 | A Better ( than Naive ) Solution to find all divisors ; method to print the divisors ; Note that this loop runs till square root ; If divisors are equal , print only one ; Otherwise print both ; Driver method\\\"\\nSolution in C#:\",\"targets\":\"using System ; class GFG { static void printDivisors ( int n ) { for ( int i = 1 ; i <= Math . Sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( n \\/ i == i ) Console . Write ( i + \\\" ▁ \\\" ) ; else Console . Write ( i + \\\" ▁ \\\" + n \\/ i + \\\" ▁ \\\" ) ; } } } public static void Main ( ) { Console . Write ( \\\" The ▁ divisors ▁ of ▁ \\\" + \\\"100 ▁ are : ▁ \\n \\\" ) ; printDivisors ( 100 ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Check whether the given number is Wagstaff prime or not | Function to check if a number is prime or not ; Corner cases ; This is checked so that we can skip middle five numbers in below loop ; Utility function to check power of two ; Driver Code ; Check if number is prime and of the form ( 2 ^ q + 1 ) \\/ 3\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function isPrime ( $ n ) { if ( $ n <= 1 ) return false ; if ( $ n <= 3 ) return true ; if ( $ n % 2 == 0 or $ n % 3 == 0 ) return false ; for ( $ i = 5 ; $ i * $ i <= $ n ; $ i = $ i + 6 ) { if ( $ n % $ i == 0 or $ n % ( $ i + 2 ) == 0 ) { return false ; } } return true ; } function isPowerOfTwo ( $ n ) { return ( $ n && ! ( $ n & ( $ n - 1 ) ) ) ; } $ n = 43 ; if ( isPrime ( $ n ) && ( isPowerOfTwo ( $ n * 3 - 1 ) ) ) { echo \\\" YES \\\" ; } else { echo \\\" NO \\\" ; } ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Find nth number that contains the digit k or divisible by k . | Function for checking if digit k is in n or not ; finding remainder ; if digit found ; Function for finding nth number ; since k is the first which satisfy the criteria , so consider it in count making count = 1 and starting from i = k + 1 ; checking that the number contain k digit or divisible by k ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function checkdigit ( $ n , $ k ) { while ( $ n ) { $ rem = $ n % 10 ; if ( $ rem == $ k ) return 1 ; $ n = $ n \\/ 10 ; } return 0 ; } function findNthNumber ( $ n , $ k ) { for ( $ i = $ k + 1 , $ count = 1 ; $ count < $ n ; $ i ++ ) { if ( checkdigit ( $ i , $ k ) || ( $ i % $ k == 0 ) ) $ count ++ ; if ( $ count == $ n ) return $ i ; } return -1 ; } $ n = 10 ; $ k = 2 ; echo findNthNumber ( $ n , $ k ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Count rotations required to sort given array in non | Function to count minimum anti - clockwise rotations required to sort the array in non - increasing order ; Stores count of arr [ i + 1 ] > arr [ i ] ; Store last index of arr [ i + 1 ] > arr [ i ] ; Traverse the given array ; If the adjacent elements are in increasing order ; Increment count ; Update index ; Prthe result according to the following conditions ; Otherwise , it is not possible to sort the array ; Given array ; Function Call\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def minMovesToSort ( arr , N ) :\\n\\tcount = 0\\n\\tindex = 0\\n\\tfor i in range ( N - 1 ) :\\n\\t\\tif ( arr [ i ] < arr [ i + 1 ] ) :\\n\\t\\t\\tcount += 1\\n\\t\\t\\tindex = i\\n\\tif ( count == 0 ) :\\n\\t\\tprint ( \\\"0\\\" )\\n\\telif ( count == N - 1 ) :\\n\\t\\tprint ( N - 1 )\\n\\telif ( count == 1 and arr [ 0 ] <= arr [ N - 1 ] ) :\\n\\t\\tprint ( index + 1 )\\n\\telse :\\n\\t\\tprint ( \\\" - 1\\\" )\\narr = [ 2 , 1 , 5 , 4 , 2 ]\\nN = len ( arr )\\nminMovesToSort ( arr , N )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Largest cone that can be inscribed within a cube | Function to find the radius of the cone ; side cannot be negative ; radius of the cone ; Function to find the height of the cone ; side cannot be negative ; height of the cone ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function coneRadius ( $ a ) { if ( $ a < 0 ) return -1 ; $ r = $ a \\/ sqrt ( 2 ) ; return $ r ; } function coneHeight ( $ a ) { if ( $ a < 0 ) return -1 ; $ h = $ a ; return $ h ; } $ a = 6 ; echo ( \\\" r ▁ = ▁ \\\" ) ; echo coneRadius ( $ a ) ; echo ( \\\" , ▁ \\\" ) ; echo ( \\\" h ▁ = ▁ \\\" ) ; echo ( coneHeight ( $ a ) ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Check if a string has m consecutive 1 ' s ▁ or ▁ 0' s | Program to check if the binary string contains m consecutive 1 ' s ▁ or ▁ 0' s ; Function that checks if the binary string contains m consecutive 1 ' s ▁ or ▁ 0' s ; length of binary string ; counts zeros ; counts 1 's ; count consecutive 0 's ; count consecutive 1 's ; Drivers Code ; function call\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . io . * ; class GFG { static boolean check ( String s , int m ) { int l = s . length ( ) ; int c1 = 0 ; int c2 = 0 ; for ( int i = 0 ; i < l ; i ++ ) { if ( s . charAt ( i ) == '0' ) { c2 = 0 ; c1 ++ ; } else { c1 = 0 ; c2 ++ ; } if ( c1 == m c2 == m ) return true ; } return false ; } public static void main ( String [ ] args ) { String s = \\\"001001\\\" ; int m = 2 ; if ( check ( s , m ) ) System . out . println ( \\\" YES \\\" ) ; else System . out . println ( \\\" NO \\\" ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Count set bits in an integer | C program to Count set bits in an integer ; Function to get no of set bits in binary representation of positive integer n ; Program to test function countSetBits\\\"\\nSolution in C:\",\"targets\":\"#include \\nunsigned int countSetBits ( unsigned int n ) { unsigned int count = 0 ; while ( n ) { count += n & 1 ; n >>= 1 ; } return count ; } int main ( ) { int i = 9 ; printf ( \\\" % d \\\" , countSetBits ( i ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Interquartile Range ( IQR ) | Function to give index of the median ; Function to calculate IQR ; Index of median of entire data ; Median of first half ; Median of second half ; IQR calculation ; Driver Function\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def median ( a , l , r ) :\\n\\tn = r - l + 1\\n\\tn = ( n + 1 ) \\/\\/ 2 - 1\\n\\treturn n + l\\ndef IQR ( a , n ) :\\n\\ta . sort ( )\\n\\tmid_index = median ( a , 0 , n )\\n\\tQ1 = a [ median ( a , 0 , mid_index ) ]\\n\\tQ3 = a [ mid_index + median ( a , mid_index + 1 , n ) ]\\n\\treturn ( Q3 - Q1 )\\nif __name__ == ' _ _ main _ _ ' :\\n\\ta = [ 1 , 19 , 7 , 6 , 5 , 9 , 12 , 27 , 18 , 2 , 15 ]\\n\\tn = len ( a )\\n\\tprint ( IQR ( a , n ) )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Minimum cost to form a number X by adding up powers of 2 | Function to return the minimum cost ; Re - compute the array ; Add answers for set bits ; If bit is set ; Increase the counter ; Right shift the number ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function MinimumCost ( $ a , $ n , $ x ) { for ( $ i = 1 ; $ i < $ n ; $ i ++ ) { $ a [ $ i ] = min ( $ a [ $ i ] , 2 * $ a [ $ i - 1 ] ) ; } $ ind = 0 ; $ sum = 0 ; while ( $ x ) { if ( $ x & 1 ) $ sum += $ a [ $ ind ] ; $ ind ++ ; $ x = $ x >> 1 ; } return $ sum ; } $ a = array ( 20 , 50 , 60 , 90 ) ; $ x = 7 ; $ n = sizeof ( $ a ) \\/ sizeof ( $ a [ 0 ] ) ; echo MinimumCost ( $ a , $ n , $ x ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Find the n | Javascript program to find n - th number whose binary representation is palindrome . ; Finds if the kth bit is set in the binary representation ; Returns the position of leftmost set bit in the binary representation ; Finds whether the integer in binary representation is palindrome or not ; One by one compare bits ; Compare left and right bits and converge ; Start from 1 , traverse through all the integers ; If we reach n , break the loop ; Driver code ; Function Call\\\"\\nSolution in Javascript:\",\"targets\":\"let INT_MAX = 2147483647 ; function isKthBitSet ( x , k ) { return ( ( x & ( 1 << ( k - 1 ) ) ) > 0 ) ? 1 : 0 ; } function leftmostSetBit ( x ) { let count = 0 ; while ( x > 0 ) { count ++ ; x = x >> 1 ; } return count ; } function isBinPalindrome ( x ) { let l = leftmostSetBit ( x ) ; let r = 1 ; while ( l > r ) { if ( isKthBitSet ( x , l ) != isKthBitSet ( x , r ) ) return 0 ; l -- ; r ++ ; } return 1 ; } function findNthPalindrome ( n ) { let pal_count = 0 ; let i = 0 ; for ( i = 1 ; i <= INT_MAX ; i ++ ) { if ( isBinPalindrome ( i ) > 0 ) { pal_count ++ ; } if ( pal_count == n ) break ; } return i ; } let n = 9 ; document . write ( findNthPalindrome ( n ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Maximum number of pairs of distinct array elements possible by including each element in only one pair | Function to count the maximum number of pairs having different element from the given array ; Stores the frequency of array element ; Stores maximum count of pairs ; Increasing the frequency of every element ; Stores the frequencies of array element from highest to lowest ; Pushing the frequencies to the priority queue ; Iterate until size of PQ > 1 ; Stores the top two element ; Form the pair between the top two pairs ; Decrement the frequencies ; Insert updated frequencies if it is greater than 0 ; Return the total count of resultant pairs ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def maximumPairs ( a , n ) :\\n\\tfreq = { }\\n\\tcount = 0\\n\\tfor i in range ( n ) :\\n\\t\\tif a [ i ] in freq :\\n\\t\\t\\tfreq [ a [ i ] ] += 1\\n\\t\\telse :\\n\\t\\t\\tfreq [ a [ i ] ] = 1\\n\\tpq = [ ]\\n\\tfor key , value in freq . items ( ) :\\n\\t\\tpq . append ( value )\\n\\tpq . sort ( )\\n\\twhile ( len ( pq ) > 1 ) :\\n\\t\\tfreq1 = pq [ len ( pq ) - 1 ]\\n\\t\\tpq = pq [ : - 1 ]\\n\\t\\tfreq2 = pq [ len ( pq ) - 1 ]\\n\\t\\tpq = pq [ : - 1 ]\\n\\t\\tcount += 1\\n\\t\\tfreq1 -= 1\\n\\t\\tfreq2 -= 1\\n\\t\\tif ( freq1 > 0 ) :\\n\\t\\t\\tpq . append ( freq1 )\\n\\t\\tif ( freq2 > 0 ) :\\n\\t\\t\\tpq . append ( freq2 )\\n\\t\\tpq . sort ( )\\n\\treturn count\\nif __name__ == ' _ _ main _ _ ' :\\n\\tarr = [ 4 , 2 , 4 , 1 , 4 , 3 ]\\n\\tN = len ( arr )\\n\\tprint ( maximumPairs ( arr , N ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Primality Test | Set 1 ( Introduction and School Method ) | A school method based JAVA program to check if a number is prime ; Corner case ; Check from 2 to n - 1 ; Driver Program\\\"\\nHow can the above be solved in Java?\",\"targets\":\"class GFG { static boolean isPrime ( int n ) { if ( n <= 1 ) return false ; for ( int i = 2 ; i < n ; i ++ ) if ( n % i == 0 ) return false ; return true ; } public static void main ( String args [ ] ) { if ( isPrime ( 11 ) ) System . out . println ( \\\" ▁ true \\\" ) ; else System . out . println ( \\\" ▁ false \\\" ) ; if ( isPrime ( 15 ) ) System . out . println ( \\\" ▁ true \\\" ) ; else System . out . println ( \\\" ▁ false \\\" ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"Subtract 1 without arithmetic operators | C code to subtract one from a given number ; Flip all the set bits until we find a 1 ; flip the rightmost 1 bit ; Driver program to test above functions\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint subtractOne ( int x ) { int m = 1 ; while ( ! ( x & m ) ) { x = x ^ m ; m <<= 1 ; } x = x ^ m ; return x ; } int main ( ) { printf ( \\\" % d \\\" , subtractOne ( 13 ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Sort an Array which contain 1 to N values in O ( N ) using Cycle Sort | Function to print array element ; Traverse the array ; Function to sort the array in O ( N ) ; Traverse the array ; If the current element is at correct position ; Else swap the current element with it 's correct position ; Swap the value of arr [ i ] and arr [ arr [ i ] - 1 ] ; Driver Code ; Function call to sort the array ; Function call to print the array\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function printArray ( arr , N ) { for ( var i = 0 ; i < N ; i ++ ) { document . write ( arr [ i ] + ' ' ) ; } } function sortArray ( arr , N ) { for ( var i = 0 ; i < N ; ) { if ( arr [ i ] == i + 1 ) { i ++ ; } else { var temp1 = arr [ i ] ; var temp2 = arr [ arr [ i ] - 1 ] ; arr [ i ] = temp2 ; arr [ temp1 - 1 ] = temp1 ; } } } var arr = [ 2 , 1 , 5 , 3 , 4 ] ; var N = arr . length ; sortArray ( arr , N ) ; printArray ( arr , N ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Strings formed from given characters without any consecutive repeating characters | C # implementation of the above approach ; Function to print the strings which satisfy the mentioned conditions ; Iterate through all the strings in the array . ; check function to check the conditions for every string ; Function to check whether the string contains any consecutive repetitive characters and any characters other than those in str ; Valid characters check ; Nonrepetitive check ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { public static void getStrings ( String str , String [ ] arr ) { for ( int i = 0 ; i < arr . Length ; i ++ ) { if ( check ( arr [ i ] , str ) ) { Console . Write ( arr [ i ] + \\\" ▁ \\\" ) ; } } } public static bool check ( String s , String str ) { char [ ] chars = s . ToCharArray ( ) ; foreach ( char c in chars ) { if ( ! str . Contains ( String . Join ( \\\" \\\" , c ) ) ) { return false ; } } for ( int i = 0 ; i < chars . Length - 1 ; i ++ ) { if ( chars [ i ] == chars [ i + 1 ] ) { return false ; } } return true ; } public static void Main ( String [ ] args ) { String str = \\\" ABCD \\\" ; String [ ] arr = { \\\" AABCDA \\\" , \\\" ABCDZADC \\\" , \\\" ABCDBCA \\\" , \\\" ABCDABDCA \\\" } ; getStrings ( str , arr ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Program to find whether a no is power of two | ; Function to check if x is power of 2 ; First x in the below expression is for the case when x is 0 ; Driver program to test above function\\\"\\nSolution in C:\",\"targets\":\"#include \\n#define bool int\\nbool isPowerOfTwo ( int x ) { return x && ( ! ( x & ( x - 1 ) ) ) ; } int main ( ) { isPowerOfTwo ( 31 ) ? printf ( \\\" Yes \\n \\\" ) : printf ( \\\" No \\n \\\" ) ; isPowerOfTwo ( 64 ) ? printf ( \\\" Yes \\n \\\" ) : printf ( \\\" No \\n \\\" ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Finding minimum vertex cover size of a graph using binary search | A Java program to find size of minimum vertex cover using Binary Search ; Global array to store the graph Note : since the array is global , all the elements are 0 initially ; Returns true if there is a possible subset of size ' k ' that can be a vertex cover ; Set has first ' k ' bits high initially ; to mark the edges covered in each subset of size ' k ' ; Reset visited array for every subset of vertices ; set counter for number of edges covered from this subset of vertices to zero ; selected vertex cover is the indices where ' set ' has its bit high ; Mark all edges emerging out of this vertex visited ; If the current subset covers all the edges ; Generate previous combination with k bits high set & - set = ( 1 << last bit high in set ) ; Returns answer to graph stored in gr [ ] [ ] ; Binary search the answer ; at the end of while loop both left and right will be equal , \\/ as when they are not , the while loop won 't exit the minimum size vertex cover = left = right ; Inserts an edge in the graph ; Undirected graph ; Driver code ; 6 \\/ 1 -- -- - 5 vertex cover = { 1 , 2 } \\/ | \\\\ 3 | \\\\ \\\\ | \\\\ 2 4 ; Let us create another graph ; 2 -- -- 4 -- -- 6 \\/ | | 1 | | vertex cover = { 2 , 3 , 4 } \\\\ | | 3 -- -- 5\\\"\\nSolution in Java:\",\"targets\":\"class GFG { static final int maxn = 25 ; static boolean [ ] [ ] gr = new boolean [ maxn ] [ maxn ] ; static boolean isCover ( int V , int k , int E ) { int set = ( 1 << k ) - 1 ; int limit = ( 1 << V ) ; boolean [ ] [ ] vis = new boolean [ maxn ] [ maxn ] ; ; while ( set < limit ) { for ( int i = 0 ; i < maxn ; i ++ ) { for ( int j = 0 ; j < maxn ; j ++ ) { vis [ i ] [ j ] = false ; } } int cnt = 0 ; for ( int j = 1 , v = 1 ; j < limit ; j = j << 1 , v ++ ) { if ( ( set & j ) != 0 ) { for ( int co = 1 ; co <= V ; co ++ ) { if ( gr [ v ] [ co ] && ! vis [ v ] [ co ] ) { vis [ v ] [ co ] = true ; vis [ co ] [ v ] = true ; cnt ++ ; } } } } if ( cnt == E ) return true ; int co = set & - set ; int ro = set + co ; set = ( ( ( ro ^ set ) >> 2 ) \\/ co ) | ro ; } return false ; } static int findMinCover ( int n , int m ) { int left = 1 , right = n ; while ( right > left ) { int mid = ( left + right ) >> 1 ; if ( isCover ( n , mid , m ) == false ) left = mid + 1 ; else right = mid ; } return left ; } static void insertEdge ( int u , int v ) { gr [ u ] [ v ] = true ; gr [ v ] [ u ] = true ; } public static void main ( String [ ] args ) { int V = 6 , E = 6 ; insertEdge ( 1 , 2 ) ; insertEdge ( 2 , 3 ) ; insertEdge ( 1 , 3 ) ; insertEdge ( 1 , 4 ) ; insertEdge ( 1 , 5 ) ; insertEdge ( 1 , 6 ) ; System . out . print ( \\\" Minimum ▁ size ▁ of ▁ a ▁ vertex ▁ cover ▁ = ▁ \\\" + findMinCover ( V , E ) + \\\"\\n\\\"); for ( int i = 0 ; i < maxn ; i ++ ) { for ( int j = 0 ; j < maxn ; j ++ ) { gr [ i ] [ j ] = false ; } } V = 6 ; E = 7 ; insertEdge ( 1 , 2 ) ; insertEdge ( 1 , 3 ) ; insertEdge ( 2 , 3 ) ; insertEdge ( 2 , 4 ) ; insertEdge ( 3 , 5 ) ; insertEdge ( 4 , 5 ) ; insertEdge ( 4 , 6 ) ; System . out . print ( \\\" Minimum ▁ size ▁ of ▁ a ▁ vertex ▁ cover ▁ = ▁ \\\" + findMinCover ( V , E ) + \\\"\\n\\\"); } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Detect loop in a linked list | C program to detect loop in a linked list ; Link list node ; allocate node ; put in the data ; link the old list off the new node ; move the head to point to the new node ; Driver program to test above function ; Start with the empty list ; Create a loop for testing\\\"\\nSolution in C:\",\"targets\":\"#include \\n#include \\nstruct Node { int data ; struct Node * next ; } ; void push ( struct Node * * head_ref , int new_data ) { struct Node * new_node = ( struct Node * ) malloc ( sizeof ( struct Node ) ) ; new_node -> data = new_data ; new_node -> next = ( * head_ref ) ; ( * head_ref ) = new_node ; } int detectLoop ( struct Node * list ) { struct Node * slow_p = list , * fast_p = list ; while ( slow_p && fast_p && fast_p -> next ) { slow_p = slow_p -> next ; fast_p = fast_p -> next -> next ; if ( slow_p == fast_p ) { return 1 ; } } return 0 ; } int main ( ) { struct Node * head = NULL ; push ( & head , 20 ) ; push ( & head , 4 ) ; push ( & head , 15 ) ; push ( & head , 10 ) ; head -> next -> next -> next -> next = head ; if ( detectLoop ( head ) ) printf ( \\\" Loop ▁ found \\\" ) ; else printf ( \\\" No ▁ Loop \\\" ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Number with maximum number of prime factors | Return smallest number having maximum prime factors . ; default value of boolean is false ; Sieve of eratosthenes ; Storing prime numbers . ; Generating number having maximum prime factors . ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function maxPrimefactorNum ( $ N ) { $ arr = array_fill ( 0 , $ N + 5 , true ) ; for ( $ i = 3 ; $ i * $ i <= $ N ; $ i += 2 ) { if ( $ arr [ $ i ] ) for ( $ j = $ i * $ i ; $ j <= $ N ; $ j += $ i ) $ arr [ $ j ] = false ; } $ prime = array ( ) ; array_push ( $ prime , 2 ) ; for ( $ i = 3 ; $ i <= $ N ; $ i += 2 ) if ( $ arr [ $ i ] ) array_push ( $ prime , $ i ) ; $ i = 0 ; $ ans = 1 ; while ( $ ans * $ prime [ $ i ] <= $ N && $ i < count ( $ prime ) ) { $ ans *= $ prime [ $ i ] ; $ i ++ ; } return $ ans ; } $ N = 40 ; print ( maxPrimefactorNum ( $ N ) ) ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Stable Selection Sort | Java program for modifying Selection Sort so that it becomes stable . ; Iterate through array elements ; Find minimum element from arr [ i ] to arr [ n - 1 ] . ; Move minimum element at current i . ; Driver code\\\"\\nSolution in Java:\",\"targets\":\"class GFG { static void stableSelectionSort ( int [ ] a , int n ) { for ( int i = 0 ; i < n - 1 ; i ++ ) { int min = i ; for ( int j = i + 1 ; j < n ; j ++ ) if ( a [ min ] > a [ j ] ) min = j ; int key = a [ min ] ; while ( min > i ) { a [ min ] = a [ min - 1 ] ; min -- ; } a [ i ] = key ; } } static void printArray ( int [ ] a , int n ) { for ( int i = 0 ; i < n ; i ++ ) System . out . print ( a [ i ] + \\\" ▁ \\\" ) ; System . out . println ( ) ; } public static void main ( String [ ] args ) { int [ ] a = { 4 , 5 , 3 , 2 , 4 , 1 } ; int n = a . length ; stableSelectionSort ( a , n ) ; printArray ( a , n ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"Decode an Encoded Base 64 String to ASCII String | C Program to decode a base64 Encoded string back to ASCII string ; char_set = \\\" ABCDEFGHIJKLMNOPQRSTUVWXYZ ▁ abcdefghijklmnopqrstuvwxyz0123456789 + \\/ \\\" ; stores the bitstream . ; count_bits stores current number of bits in num . ; selects 4 characters from encoded string at a time . find the position of each encoded character in char_set and stores in num . ; make space for 6 bits . ; encoded [ i + j ] = ' E ' , ' E ' - ' A ' = 5 ' E ' has 5 th position in char_set . ; encoded [ i + j ] = ' e ' , ' e ' - ' a ' = 5 , 5 + 26 = 31 , ' e ' has 31 st position in char_set . ; encoded [ i + j ] = '8' , '8' - '0' = 8 8 + 52 = 60 , '8' has 60 th position in char_set . ; ' + ' occurs in 62 nd position in char_set . ; ' \\/ ' occurs in 63 rd position in char_set . ; ( str [ i + j ] == ' = ' ) remove 2 bits to delete appended bits during encoding . ; 255 in binary is 11111111 ; Driver function ; Do not count last NULL character .\\nHow can the above be solved in C?\",\"targets\":\"#include \\n#include \\n#define SIZE 100\\nchar * base64Decoder ( char encoded [ ] , int len_str ) { char * decoded_string ; decoded_string = ( char * ) malloc ( sizeof ( char ) * SIZE ) ; int i , j , k = 0 ; int num = 0 ; int count_bits = 0 ; for ( i = 0 ; i < len_str ; i += 4 ) { num = 0 , count_bits = 0 ; for ( j = 0 ; j < 4 ; j ++ ) { if ( encoded [ i + j ] != ' = ' ) { num = num << 6 ; count_bits += 6 ; } if ( encoded [ i + j ] >= ' A ' && encoded [ i + j ] <= ' Z ' ) num = num | ( encoded [ i + j ] - ' A ' ) ; else if ( encoded [ i + j ] >= ' a ' && encoded [ i + j ] <= ' z ' ) num = num | ( encoded [ i + j ] - ' a ' + 26 ) ; else if ( encoded [ i + j ] >= '0' && encoded [ i + j ] <= '9' ) num = num | ( encoded [ i + j ] - '0' + 52 ) ; else if ( encoded [ i + j ] == ' + ' ) num = num | 62 ; else if ( encoded [ i + j ] == ' \\/ ' ) num = num | 63 ; else { num = num >> 2 ; count_bits -= 2 ; } } while ( count_bits != 0 ) { count_bits -= 8 ; decoded_string [ k ++ ] = ( num >> count_bits ) & 255 ; } } decoded_string [ k ] = ' \\\\0' ; return decoded_string ; } int main ( ) { char encoded_string [ ] = \\\" TUVOT04 = \\\" ; int len_str = sizeof ( encoded_string ) \\/ sizeof ( encoded_string [ 0 ] ) ; len_str -= 1 ; printf ( \\\" Encoded ▁ string ▁ : ▁ % s \\n \\\" , encoded_string ) ; printf ( \\\" Decoded _ string ▁ : ▁ % s \\n \\\" , base64Decoder ( encoded_string , len_str ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Program to find the Perimeter of a Regular Polygon | C program to find the perimeter of a regular polygon ; Function to calculate the perimeter ; Calculate Perimeter ; driver code ; Get the number of sides ; Get the length of side ; find perimeter\\\"\\nSolution in C:\",\"targets\":\"#include \\nfloat Perimeter ( float s , int n ) { float perimeter = 1 ; perimeter = n * s ; return perimeter ; } int main ( ) { int n = 5 ; float s = 2.5 , peri ; peri = Perimeter ( s , n ) ; printf ( \\\" Perimeter ▁ of ▁ Regular ▁ Polygon \\n \\\" \\\" ▁ with ▁ % d ▁ sides ▁ of ▁ length ▁ % f ▁ = ▁ % f \\n \\\" , n , s , peri ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Modify a given array by replacing each element with the sum or product of their digits based on a given condition | Function to modify the given array as per the given conditions ; Traverse the given array arr [ ] ; Initialize the count of even and odd digits ; Initialize temp with the current array element ; For count the number of even digits ; Increment the odd count ; Otherwise ; Divide temp by 10 ; Performe addition ; Performe multiplication ; Otherwise ; Driver Code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"def evenOdd ( arr , N ) :\\n\\tfor i in range ( N ) :\\n\\t\\teven_digits = 0 ;\\n\\t\\todd_digits = 0 ;\\n\\t\\ttemp = arr [ i ] ;\\n\\t\\twhile ( temp ) :\\n\\t\\t\\tif ( ( temp % 10 ) & 1 ) :\\n\\t\\t\\t\\todd_digits += 1 ;\\n\\t\\t\\telse :\\n\\t\\t\\t\\teven_digits += 1 ;\\n\\t\\t\\ttemp = temp \\/\\/ 10\\n\\t\\tif ( even_digits > odd_digits ) :\\n\\t\\t\\tres = 0 ;\\n\\t\\t\\twhile ( arr [ i ] ) :\\n\\t\\t\\t\\tres += arr [ i ] % 10 ;\\n\\t\\t\\t\\tarr [ i ] = arr [ i ] \\/\\/ 10 ;\\n\\t\\t\\tprint ( res , end = \\\" ▁ \\\" ) ;\\n\\t\\telif ( odd_digits > even_digits ) :\\n\\t\\t\\tres = 1 ;\\n\\t\\t\\twhile ( arr [ i ] ) :\\n\\t\\t\\t\\tres *= arr [ i ] % 10 ;\\n\\t\\t\\t\\tarr [ i ] = arr [ i ] \\/\\/ 10\\n\\t\\t\\tprint ( res , end = \\\" ▁ \\\" ) ;\\n\\t\\telse :\\n\\t\\t\\tprint ( arr [ i ] , end = \\\" ▁ \\\" ) ;\\narr = [ 113 , 141 , 214 , 3186 ] ;\\nN = len ( arr ) ;\\nevenOdd ( arr , N ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Queries to count Palindrome Numbers from a range whose sum of digits is a Prime Number | Java program for the above approach ; Function to check if the number N is palindrome or not ; Store the value of N ; Store the reverse of number N ; Reverse temp and store in res ; If N is the same as res , then return true ; Function to find the sum of the digits of the number N ; Stores the sum of the digits ; Add the last digit of the number N to the sum ; Remove the last digit from N ; Return the resultant sum ; Function to check if N is prime or not ; If i is 1 or 0 , then return false ; Check if i is divisible by any number in the range [ 2 , n \\/ 2 ] ; If n is divisible by i ; Function to precompute all the numbers till 10 ^ 5 that are palindromic and whose sum of digits is prime numbers ; Iterate over the range 1 to 10 ^ 5 ; If i is a palindrome number ; Stores the sum of the digits in i ; If the sum of digits in i is a prime number ; Find the prefix sum of arr [ ] ; Function to count all the numbers in the given ranges that are palindromic and the sum of digits is prime numbers ; Function Call to precompute all the numbers till 10 ^ 5 ; Traverse the given queries Q [ ] ; Print the result for each query ; Driver Code ; Function Call\\\"\\nHow can the above be solved in Java?\",\"targets\":\"class GFG { static int [ ] arr = new int [ 100005 ] ; static boolean isPalindrome ( int N ) { int temp = N ; int res = 0 ; while ( temp != 0 ) { int rem = temp % 10 ; res = res * 10 + rem ; temp \\/= 10 ; } if ( res == N ) { return true ; } else { return false ; } } static int sumOfDigits ( int N ) { int sum = 0 ; while ( N != 0 ) { sum += N % 10 ; N \\/= 10 ; } return sum ; } static boolean isPrime ( int n ) { if ( n <= 1 ) { return false ; } for ( int i = 2 ; i <= n \\/ 2 ; ++ i ) { if ( n % i == 0 ) return false ; } return true ; } static void precompute ( ) { for ( int i = 1 ; i <= 100000 ; i ++ ) { if ( isPalindrome ( i ) ) { int sum = sumOfDigits ( i ) ; if ( isPrime ( sum ) ) arr [ i ] = 1 ; else arr [ i ] = 0 ; } else arr [ i ] = 0 ; } for ( int i = 1 ; i <= 100000 ; i ++ ) { arr [ i ] = arr [ i ] + arr [ i - 1 ] ; } } static void countNumbers ( int [ ] [ ] Q , int N ) { precompute ( ) ; for ( int i = 0 ; i < N ; i ++ ) { System . out . println ( ( arr [ Q [ i ] [ 1 ] ] - arr [ Q [ i ] [ 0 ] - 1 ] ) ) ; } } public static void main ( String [ ] args ) { int [ ] [ ] Q = { { 5 , 9 } , { 1 , 101 } } ; int N = Q . length ; countNumbers ( Q , N ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Maximum array sum that can be obtained after exactly k changes | C # implementation of the above approach ; Utility function to return the sum of the array elements ; Function to return the maximized sum of the array after performing the given operation exactly k times ; Sort the array elements ; Change signs of the negative elements starting from the smallest ; If a single operation has to be performed then it must be performed on the smallest positive element ; To store the index of the minimum element ; Update the minimum index ; Perform remaining operation on the smallest element ; Return the sum of the updated array ; Driver code\\\"\\nSolution in C#:\",\"targets\":\"using System ; using System . Linq ; class GFG { static int sumArr ( int [ ] arr , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; return sum ; } static int maxSum ( int [ ] arr , int n , int k ) { Array . Sort ( arr ) ; int i = 0 ; while ( i < n && k > 0 && arr [ i ] < 0 ) { arr [ i ] *= - 1 ; k -- ; i ++ ; } if ( k % 2 == 1 ) { int min = 0 ; for ( i = 1 ; i < n ; i ++ ) if ( arr [ min ] > arr [ i ] ) min = i ; arr [ min ] *= - 1 ; } return sumArr ( arr , n ) ; } static void Main ( ) { int [ ] arr = { - 5 , 4 , 1 , 3 , 2 } ; int n = arr . Length ; int k = 4 ; Console . WriteLine ( maxSum ( arr , n , k ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solcsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Count twin prime pairs in an Array | Python 3 program to count Twin Prime pairs in array ; A utility function to check if the number n is prime or not ; Base Cases ; Check to skip middle five numbers in below loop ; If n is divisible by i and i + 2 then it is not prime ; A utility function that check if n1 and n2 are Twin Primes or not ; Function to find Twin Prime pairs from the given array ; Iterate through all pairs ; Increment count if twin prime pair ; Driver 's code ; Function call to find Twin Primes pair\\\"\\nSolution in Python:\",\"targets\":\"from math import sqrt\\ndef isPrime ( n ) :\\n\\tif ( n <= 1 ) :\\n\\t\\treturn False\\n\\tif ( n <= 3 ) :\\n\\t\\treturn True\\n\\tif ( n % 2 == 0 or n % 3 == 0 ) :\\n\\t\\treturn False\\n\\tfor i in range ( 5 , int ( sqrt ( n ) ) + 1 , 6 ) :\\n\\t\\tif ( n % i == 0 or n % ( i + 2 ) == 0 ) :\\n\\t\\t\\treturn False\\n\\treturn True\\ndef twinPrime ( n1 , n2 ) :\\n\\treturn ( isPrime ( n1 ) and isPrime ( n2 ) and abs ( n1 - n2 ) == 2 )\\ndef countTwinPairs ( arr , n ) :\\n\\tcount = 0\\n\\tfor i in range ( n ) :\\n\\t\\tfor j in range ( i + 1 , n ) :\\n\\t\\t\\tif ( twinPrime ( arr [ i ] , arr [ j ] ) ) :\\n\\t\\t\\t\\tcount += 1\\n\\treturn count\\nif __name__ == ' _ _ main _ _ ' :\\n\\tarr = [ 2 , 3 , 5 , 11 ]\\n\\tn = len ( arr )\\n\\tprint ( countTwinPairs ( arr , n ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Minimum count of increment of K size subarrays required to form a given Array | C ++ implementation to find the minimum number of operations required to change an array of all zeros such that every element is greater than the given array ; Function to find the minimum number of operations required to change all the array of zeros such that every element is greater than the given array ; Declaring the difference array of size N ; Number of operations ; First update the D [ i ] value with the previous value ; The index i has to be incremented ; We have to perform ( b [ i ] - d [ i ] ) operations more ; Increment the range i to i + k by need ; Check if i + k is valid index ; Driver Code ; Function Call\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; int find_minimum_operations ( int n , int b [ ] , int k ) { int d [ n + 1 ] = { 0 } ; int operations = 0 , need ; for ( int i = 0 ; i < n ; i ++ ) { if ( i > 0 ) { d [ i ] += d [ i - 1 ] ; } if ( b [ i ] > d [ i ] ) { operations += b [ i ] - d [ i ] ; need = b [ i ] - d [ i ] ; d [ i ] += need ; if ( i + k <= n ) { d [ i + k ] -= need ; } } } cout << operations << endl ; } int main ( ) { int n = 5 ; int b [ ] = { 1 , 2 , 3 , 4 , 5 } ; int k = 2 ; find_minimum_operations ( n , b , k ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"9 's complement of a decimal number | C # program to find 9 's complement of a number. ; Driver code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static void complement ( string number1 ) { char [ ] number = number1 . ToCharArray ( ) ; for ( int i = 0 ; i < number . Length ; i ++ ) if ( number [ i ] != ' . ' ) number [ i ] = ( char ) ( ( int ) ( '9' ) - ( int ) ( number [ i ] ) + ( int ) ( '0' ) ) ; System . Console . WriteLine ( \\\"9 ' s ▁ complement ▁ is ▁ : ▁ \\\" + new string ( number ) ) ; } public static void Main ( ) { String number = \\\"345.45\\\" ; complement ( number ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"\\\"Coin Change | DP | Recursive C ++ program for coin change problem . ; Returns the count of ways we can sum S [ 0. . . m - 1 ] coins to get sum n ; If n is 0 then there is 1 solution ( do not include any coin ) ; If n is less than 0 then no solution exists ; If there are no coins and n is greater than 0 , then no solution exist ; count is sum of solutions ( i ) including S [ m - 1 ] ( ii ) excluding S [ m - 1 ] ; Driver code\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; int count ( int S [ ] , int m , int n ) { if ( n == 0 ) return 1 ; if ( n < 0 ) return 0 ; if ( m <= 0 && n >= 1 ) return 0 ; return count ( S , m - 1 , n ) + count ( S , m , n - S [ m - 1 ] ) ; } int main ( ) { int i , j ; int arr [ ] = { 1 , 2 , 3 } ; int m = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; cout << \\\" ▁ \\\" << count ( arr , m , 4 ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Largest element in the array that is repeated exactly k times | C # implementation of the above approach ; Function that finds the largest element which is repeated ' k ' times ; sort the array ; if the value of ' k ' is 1 and the largest appears only once in the array ; counter to count the repeated elements ; check if the element at index ' i ' is equal to the element at index ' i + 1' then increase the count ; else set the count to 1 to start counting the frequency of the new number ; if the count is equal to k and the previous element is not equal to this element ; if there is no such element ; Driver code ; find the largest element that is repeated K times\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static void solve ( int [ ] arr , int n , int k ) { Array . Sort ( arr ) ; if ( k == 1 && arr [ n - 2 ] != arr [ n - 1 ] ) { Console . WriteLine ( arr [ n - 1 ] ) ; return ; } int count = 1 ; for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( arr [ i ] == arr [ i + 1 ] ) count ++ ; else count = 1 ; if ( count == k && ( i == 0 || ( arr [ i - 1 ] != arr [ i ] ) ) ) { Console . WriteLine ( arr [ i ] ) ; return ; } } Console . WriteLine ( \\\" No ▁ such ▁ element \\\" ) ; } static public void Main ( ) { int [ ] arr = { 1 , 1 , 2 , 3 , 3 , 4 , 5 , 5 , 6 , 6 , 6 } ; int k = 2 ; int n = arr . Length ; solve ( arr , n , k ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n" "{\"inputs\":\"Program to find the Perimeter of a Regular Polygon | C program to find the perimeter of a regular polygon ; Function to calculate the perimeter ; Calculate Perimeter ; driver code ; Get the number of sides ; Get the length of side ; find perimeter\\nHow can the above be solved in C?\",\"targets\":\"#include \\nfloat Perimeter ( float s , int n ) { float perimeter = 1 ; perimeter = n * s ; return perimeter ; } int main ( ) { int n = 5 ; float s = 2.5 , peri ; peri = Perimeter ( s , n ) ; printf ( \\\" Perimeter ▁ of ▁ Regular ▁ Polygon \\n \\\" \\\" ▁ with ▁ % d ▁ sides ▁ of ▁ length ▁ % f ▁ = ▁ % f \\n \\\" , n , s , peri ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"Pell Number | Iterative Pell Number Series in C ; calculate nth pell number ; driver function\\nHow can the above be solved in C?\",\"targets\":\"#include \\nint pell ( int n ) { if ( n <= 2 ) return n ; int a = 1 ; int b = 2 ; int c , i ; for ( i = 3 ; i <= n ; i ++ ) { c = 2 * b + a ; a = b ; b = c ; } return b ; } int main ( ) { int n = 4 ; printf ( \\\" % d \\\" , pell ( n ) ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Comparing X ^ Y and Y ^ X for very large values of X and Y | Function to compare x ^ y and y ^ x ; Storing values OF x ^ y AND y ^ x ; Comparing values ; Driver code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function compareVal ( x , y ) { let a = y * Math . log ( x ) ; let b = x * Math . log ( y ) ; if ( a > b ) document . write ( x + \\\" \\\" + y + \\\" \\\" + y + \\\" \\\" + x ) ; else if ( a < b ) document . write ( x + \\\" \\\" + y + \\\" \\\" + y + \\\" \\\" + x ) ; else if ( a == b ) document . write ( x + \\\" \\\" + y + \\\" \\\" + y + \\\" \\\" + x ) ; } let x = 4 , y = 5 ; compareVal ( x , y ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Program to find the angles of a quadrilateral | java implementation of the approach ; Driver code ; according to formula derived above ; print all the angles\\\"\\nSolution in Java:\",\"targets\":\"import java . io . * ; class GFG { public static void main ( String [ ] args ) { int d = 10 ; double a ; a = ( double ) ( 360 - ( 6 * d ) ) \\/ 4 ; System . out . print ( a + \\\" , ▁ \\\" + ( a + d ) + \\\" , ▁ \\\" + ( a + ( 2 * d ) ) + \\\" , ▁ \\\" + ( a + ( 3 * d ) ) ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Turn off the rightmost set bit | Set 2 | Unsets the rightmost set bit of n and returns the result ; Checking whether bit position is set or not ; If bit position is found set , we flip this bit by xoring given number and number with bit position set ; Driver code\\\"\\nSolution in Python:\",\"targets\":\"def FlipBits ( n ) :\\n\\tfor bit in range ( 32 ) :\\n\\t\\tif ( ( n >> bit ) & 1 ) :\\n\\t\\t\\tn = n ^ ( 1 << bit )\\n\\t\\t\\tbreak\\n\\tprint ( \\\" The ▁ number ▁ after ▁ unsetting ▁ the \\\" , end = \\\" ▁ \\\" )\\n\\tprint ( \\\" rightmost ▁ set ▁ bit \\\" , n )\\nif __name__ == ' _ _ main _ _ ' :\\n\\tN = 12 ;\\n\\tFlipBits ( N )\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Program to find the Magnitude of a Vector | Python3 program for the above approach ; Function to calculate magnitude of a 3 dimensional vector ; Stores the sum of squares of coordinates of a vector ; Return the magnitude ; Driver code\\\"\\nHow can the above be solved in Python?\",\"targets\":\"from math import sqrt\\ndef vectorMagnitude ( x , y , z ) :\\n\\tsum = x * x + y * y + z * z\\n\\treturn sqrt ( sum )\\nx = 1\\ny = 2\\nz = 3\\nprint ( vectorMagnitude ( x , y , z ) )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovepy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Ways to split array into two groups of same XOR value | Return the count number of ways to split array into two groups such that each grouphas equal XOR value . ; We can split only if XOR is 0. Since XOR of all is 0 , we can consider all subsets as one group . ; Driver Code\\\"\\nSolution in php:\",\"targets\":\"< ? php function countgroup ( $ a , $ n ) { $ xs = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) $ xs = $ xs ^ $ a [ $ i ] ; if ( $ xs == 0 ) return ( 1 << ( $ n - 1 ) ) - 1 ; return 0 ; } $ a = array ( 1 , 2 , 3 ) ; $ n = count ( $ a ) ; echo countgroup ( $ a , $ n ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Program to print binomial expansion series | CPP program to print terms of binomial series and also calculate sum of series . ; function to print the series ; Calculating and printing first term ; Computing and printing remaining terms ; Find current term using previous terms We increment power of X by 1 , decrement power of A by 1 and compute nCi using previous term by multiplying previous term with ( n - i + 1 ) \\/ i ; main function started\\\"\\nHow can the above be solved in C++?\",\"targets\":\"#include \\nusing namespace std ; void series ( int A , int X , int n ) { int term = pow ( A , n ) ; cout << term << \\\" ▁ \\\" ; for ( int i = 1 ; i <= n ; i ++ ) { term = term * X * ( n - i + 1 ) \\/ ( i * A ) ; cout << term << \\\" ▁ \\\" ; } } int main ( ) { int A = 3 , X = 4 , n = 5 ; series ( A , X , n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovecpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Count pairs with set bits sum equal to K | Python implementation of the approach ; Function to return the count of set bits in n ; Function to return the count of required pairs ; To store the count ; Frequency array ; If current pair satisfies the given condition ; ( arr [ i ] , arr [ i ] ) cannot be a valid pair ; Driver code\\\"\\nSolution in Python:\",\"targets\":\"MAX = 32\\ndef countSetBits ( n ) :\\n\\tcount = 0 ;\\n\\twhile ( n ) :\\n\\t\\tn &= ( n - 1 ) ;\\n\\t\\tcount += 1 ;\\n\\treturn count ;\\ndef pairs ( arr , n , k ) :\\n\\tcount = 0 ;\\n\\tf = [ 0 for i in range ( MAX + 1 ) ]\\n\\tfor i in range ( n ) :\\n\\t\\tf [ countSetBits ( arr [ i ] ) ] += 1 ;\\n\\tfor i in range ( MAX + 1 ) :\\n\\t\\tfor j in range ( 1 , MAX + 1 ) :\\n\\t\\t\\tif ( i + j == k ) :\\n\\t\\t\\t\\tif ( i == j ) :\\n\\t\\t\\t\\t\\tcount += ( ( f [ i ] * ( f [ i ] - 1 ) ) \\/ 2 ) ;\\n\\t\\t\\t\\telse :\\n\\t\\t\\t\\t\\tcount += ( f [ i ] * f [ j ] ) ;\\n\\treturn count ;\\narr = [ 1 , 2 , 3 , 4 , 5 ]\\nn = len ( arr )\\nk = 4\\nprint ( pairs ( arr , n , k ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Count trailing zero bits using lookup table | Simple PHP code for counting trailing zeros in binary representation of a number ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function countTrailingZero ( $ x ) { $ count = 0 ; while ( ( $ x & 1 ) == 0 ) { $ x = $ x >> 1 ; $ count ++ ; } return $ count ; } echo countTrailingZero ( 11 ) , \\\" \\n \\\" ; ? >\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Divide array in two maximum equal length arrays of similar and dissimilar elements | Java program to find the max - size to which an array can be divided into 2 equal parts such that one part contains unique elements while another contains similar elements ; Function to find the max - size to which an array can be divided into 2 equal parts ; Array to find the frequency of each element of array ; Find the index maximum frequency element present in array arr [ ] ; Find total unique elements present in array arr [ ] ; Find the Max - Size to which an array arr [ ] can be splitted ; Find the first array containing same elements ; Find the second array containing unique elements ; Driver Code ; initialise n ; array declaration ; size of array\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void Solve ( int arr [ ] , int size , int n ) { int [ ] v = new int [ n + 1 ] ; for ( int i = 0 ; i < size ; i ++ ) v [ arr [ i ] ] ++ ; int max1 = - 1 , mx = - 1 ; for ( int i = 0 ; i < v . length ; i ++ ) { if ( v [ i ] > mx ) { mx = v [ i ] ; max1 = i ; } } int cnt = 0 ; for ( int i : v ) { if ( i == 0 ) ++ cnt ; } int diff1 = n + 1 - cnt ; int max_size = Math . max ( Math . min ( v [ max1 ] - 1 , diff1 ) , Math . min ( v [ max1 ] , diff1 - 1 ) ) ; System . out . println ( \\\" Maximum ▁ size ▁ is : ▁ \\\" + max_size ) ; System . out . println ( \\\" First ▁ Array ▁ is \\\" ) ; for ( int i = 0 ; i < max_size ; i ++ ) { System . out . print ( max1 + \\\" ▁ \\\" ) ; v [ max1 ] -= 1 ; } System . out . println ( ) ; System . out . println ( \\\" The ▁ Second ▁ Array ▁ Is ▁ : \\\" ) ; for ( int i = 0 ; i < ( n + 1 ) ; i ++ ) { if ( v [ i ] > 0 ) { System . out . print ( i + \\\" ▁ \\\" ) ; max_size -- ; } if ( max_size < 1 ) break ; } System . out . println ( ) ; } public static void main ( String [ ] args ) { int n = 7 ; int arr [ ] = new int [ ] { 1 , 2 , 1 , 5 , 1 , 6 , 7 , 2 } ; int size = arr . length ; Solve ( arr , size , n ) ; } }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Calculate the value of 2 raised to the power of twice the binary representation of N | Python3 program to implement the above approach ; Function to find the value of power ( X , Y ) in O ( log Y ) ; Stores power ( X , Y ) ; Update X ; Base Case ; Calculate power ( X , Y ) ; If Y is an odd number ; Update res ; Update Y ; Update X ; Function to calculate ( 2 ^ ( 2 * x ) ) % ( 10 ^ 9 + 7 ) ; dp [ N ] * dp [ N ] : Stores value of ( 2 ^ ( 2 * x ) ) % ( 10 ^ 9 + 7 ) ; Base Case ; Iterate over the range [ 3 , N ] ; Stores rightmost bit of i ; Stores the value of ( i - y ) ; If x is power of 2 ; Update dp [ i ] ; Update dp [ i ] ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"M = 1000000007 ;\\ndef power ( X , Y ) :\\n\\tres = 1 ;\\n\\tX = X % M ;\\n\\tif ( X == 0 ) :\\n\\t\\treturn 0 ;\\n\\twhile ( Y > 0 ) :\\n\\t\\tif ( Y % 2 == 1 ) :\\n\\t\\t\\tres = ( res * X ) % M ;\\n\\t\\tY = Y >> 1 ;\\n\\t\\tX = ( X * X ) % M ;\\n\\treturn res ;\\ndef findValue ( N ) :\\n\\tdp = [ 0 ] * ( N + 1 ) ;\\n\\tdp [ 1 ] = 2 ;\\n\\tdp [ 2 ] = 1024 ;\\n\\tfor i in range ( 3 , N + 1 ) :\\n\\t\\ty = ( i & ( - i ) ) ;\\n\\t\\tx = i - y ;\\n\\t\\tif ( x == 0 ) :\\n\\t\\t\\tdp [ i ] = power ( dp [ i \\/\\/ 2 ] , 10 ) ;\\n\\t\\telse :\\n\\t\\t\\tdp [ i ] = ( dp [ x ] * dp [ y ] ) % M ;\\n\\treturn ( dp [ N ] * dp [ N ] ) % M ;\\nif __name__ == ' _ _ main _ _ ' :\\n\\tn = 150 ;\\n\\tprint ( findValue ( n ) ) ;\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"Print list items containing all characters of a given word | C program to print all strings that contain all characters of a word ; prints list items having all characters of word ; Since calloc is used , map [ ] is initialized as 0 ; Set the values in map ; Get the length of given word ; Check each item of list if has all characters of word ; unset the bit so that strings like sss not printed ; Set the values in map for next item ; Driver program to test to pront printDups\\nHow can the above be solved in C?\",\"targets\":\"# include \\n# include \\n# include \\n# define NO_OF_CHARS 256\\nvoid print ( char * list [ ] , char * word , int list_size ) { int * map = ( int * ) calloc ( sizeof ( int ) , NO_OF_CHARS ) ; int i , j , count , word_size ; for ( i = 0 ; * ( word + i ) ; i ++ ) map [ * ( word + i ) ] = 1 ; word_size = strlen ( word ) ; for ( i = 0 ; i < list_size ; i ++ ) { for ( j = 0 , count = 0 ; * ( list [ i ] + j ) ; j ++ ) { if ( map [ * ( list [ i ] + j ) ] ) { count ++ ; map [ * ( list [ i ] + j ) ] = 0 ; } } if ( count == word_size ) printf ( \\\" % s \\\" , list [ i ] ) ; for ( j = 0 ; * ( word + j ) ; j ++ ) map [ * ( word + j ) ] = 1 ; } } int main ( ) { char str [ ] = \\\" sun \\\" ; char * list [ ] = { \\\" geeksforgeeks \\\" , \\\" unsorted \\\" , \\\" sunday \\\" , \\\" just \\\" , \\\" sss \\\" } ; print ( list , str , 5 ) ; getchar ( ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovec\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Pancake sorting | C program to sort array using pancake sort ; Reverses arr [ 0. . i ] ; Returns index of the maximum element in arr [ 0. . n - 1 ] ; The main function that sorts given array using flip operations ; Start from the complete array and one by one reduce current size by one ; Find index of the maximum element in arr [ 0. . curr_size - 1 ] ; Move the maximum element to end of current array if it 's not already at the end ; To move at the end , first move maximum number to beginning ; Now move the maximum number to end by reversing current array ; A utility function to print n array of size n ; Driver program to test above function\\\"\\nSolution in C:\",\"targets\":\"#include \\n#include \\nvoid flip ( int arr [ ] , int i ) { int temp , start = 0 ; while ( start < i ) { temp = arr [ start ] ; arr [ start ] = arr [ i ] ; arr [ i ] = temp ; start ++ ; i -- ; } } int findMax ( int arr [ ] , int n ) { int mi , i ; for ( mi = 0 , i = 0 ; i < n ; ++ i ) if ( arr [ i ] > arr [ mi ] ) mi = i ; return mi ; } void pancakeSort ( int * arr , int n ) { for ( int curr_size = n ; curr_size > 1 ; -- curr_size ) { int mi = findMax ( arr , curr_size ) ; if ( mi != curr_size - 1 ) { flip ( arr , mi ) ; flip ( arr , curr_size - 1 ) ; } } } void printArray ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; ++ i ) printf ( \\\" % d ▁ \\\" , arr [ i ] ) ; } int main ( ) { int arr [ ] = { 23 , 10 , 20 , 11 , 12 , 6 , 7 } ; int n = sizeof ( arr ) \\/ sizeof ( arr [ 0 ] ) ; pancakeSort ( arr , n ) ; puts ( \\\" Sorted ▁ Array ▁ \\\" ) ; printArray ( arr , n ) ; return 0 ; }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solc\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C-program-level\"}\n" "{\"inputs\":\"\\\"Sum of all the numbers present at given level in Pascal 's triangle | Function to find sum of numbers at Lth level in Pascals Triangle ; Driver Code\\\"\\nSolution in Javascript:\",\"targets\":\"function sum ( h ) { return Math . pow ( 2 , h - 1 ) ; } var L = 3 ; document . write ( sum ( L ) ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Find ( 1 ^ n + 2 ^ n + 3 ^ n + 4 ^ n ) mod 5 | Set 2 | Function to return A mod B ; length of the string ; to store required answer ; Function to return ( 1 ^ n + 2 ^ n + 3 ^ n + 4 ^ n ) % 5 ; Calculate and return ans ; Driver code\\\"\\nSolution in php:\",\"targets\":\"< ? php function A_mod_B ( $ N , $ a ) { $ len = strlen ( $ N ) ; $ ans = 0 ; for ( $ i = 0 ; $ i < $ len ; $ i ++ ) $ ans = ( $ ans * 10 + ( int ) $ N [ $ i ] - '0' ) % $ a ; return $ ans % $ a ; } function findMod ( $ N ) { $ mod = A_mod_B ( $ N , 4 ) ; $ ans = ( 1 + pow ( 2 , $ mod ) + pow ( 3 , $ mod ) + pow ( 4 , $ mod ) ) ; return ( $ ans % 5 ) ; } $ N = \\\"4\\\" ; echo findMod ( $ N ) ; ? >\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Count number of indices such that s [ i ] = s [ i + 1 ] : Range queries | C ++ program to find substring with ; Function to create prefix array ; Function to return the result of the query ; Driver Code ; Query 1 ; Query 2\\\"\\nSolution in C++:\",\"targets\":\"#include \\nusing namespace std ; void preCompute ( int n , string s , int pref [ ] ) { pref [ 0 ] = 0 ; for ( int i = 1 ; i < n ; i ++ ) { pref [ i ] = pref [ i - 1 ] ; if ( s [ i - 1 ] == s [ i ] ) pref [ i ] ++ ; } } int query ( int pref [ ] , int l , int r ) { return pref [ r ] - pref [ l ] ; } int main ( ) { string s = \\\" ggggggg \\\" ; int n = s . length ( ) ; int pref [ n ] ; preCompute ( n , s , pref ) ; int l = 1 ; int r = 2 ; cout << query ( pref , l , r ) << endl ; l = 1 ; r = 5 ; cout << query ( pref , l , r ) << endl ; return 0 ; }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solcpp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"C++-program-level\"}\n" "{\"inputs\":\"\\\"Longest substring with K unique characters using Binary Search | Function that returns True if there is a sub of length len with <= k unique characters ; Size of the ; Map to store the characters and their frequency ; Update the map for the first sub ; Check for the rest of the subs ; Add the new character ; Remove the first character of the previous window ; Update the map ; Function to return the length of the longest sub which has K unique characters ; Check if the complete contains K unique characters ; Size of the ; Apply binary search ; Driver code\\\"\\nSolution in Python:\",\"targets\":\"def isValidLen ( s , lenn , k ) :\\n\\tn = len ( s )\\n\\tmp = dict ( )\\n\\tright = 0\\n\\twhile ( right < lenn ) :\\n\\t\\tmp [ s [ right ] ] = mp . get ( s [ right ] , 0 ) + 1\\n\\t\\tright += 1\\n\\tif ( len ( mp ) <= k ) :\\n\\t\\treturn True\\n\\twhile ( right < n ) :\\n\\t\\tmp [ s [ right ] ] = mp . get ( s [ right ] , 0 ) + 1\\n\\t\\tmp [ s [ right - lenn ] ] -= 1\\n\\t\\tif ( mp [ s [ right - lenn ] ] == 0 ) :\\n\\t\\t\\tdel mp [ s [ right - lenn ] ]\\n\\t\\tif ( len ( mp ) <= k ) :\\n\\t\\t\\treturn True\\n\\t\\tright += 1\\n\\treturn len ( mp ) <= k\\ndef maxLenSubStr ( s , k ) :\\n\\tuni = dict ( )\\n\\tfor x in s :\\n\\t\\tuni [ x ] = 1\\n\\tif ( len ( uni ) < k ) :\\n\\t\\treturn - 1\\n\\tn = len ( s )\\n\\tlo = - 1\\n\\thi = n + 1\\n\\twhile ( hi - lo > 1 ) :\\n\\t\\tmid = lo + hi >> 1\\n\\t\\tif ( isValidLen ( s , mid , k ) ) :\\n\\t\\t\\tlo = mid\\n\\t\\telse :\\n\\t\\t\\thi = mid\\n\\treturn lo\\ns = \\\" aabacbebebe \\\"\\nk = 3\\nprint ( maxLenSubStr ( s , k ) )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Find the minimum number of elements that should be removed to make an array good | Java program to remove minimum elements to make the given array good ; Function to remove minimum elements to make the given array good ; To store count of each subsequence ; Increase the count of subsequence [ 0 ] ; If Previous element subsequence count is greater than zero then increment subsequence count of current element and decrement subsequence count of the previous element . ; Return the required answer ; Driver code ; Function call\\\"\\nSolution in Java:\",\"targets\":\"import java . util . Collections ; import java . util . Vector ; class GFG { static int MinRemove ( int [ ] a , int n , int k ) { int [ ] cnt = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 0 ) cnt [ 0 ] ++ ; else if ( cnt [ a [ i ] - 1 ] > 0 ) { cnt [ a [ i ] - 1 ] -- ; cnt [ a [ i ] ] ++ ; } } return n - ( k * cnt [ k - 1 ] ) ; } public static void main ( String [ ] args ) { int a [ ] = { 0 , 1 , 2 , 3 , 4 , 0 , 1 , 0 , 1 , 2 , 3 , 4 } ; int k = 5 ; int n = a . length ; System . out . println ( MinRemove ( a , n , k ) ) ; } }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Split a number as sum of K numbers which are not divisible by K | Function to split into K parts and print them ; Print 1 K - 1 times ; Print N - K + 1 ; Print 1 K - 2 times ; Print 2 and N - K ; Driver code\\\"\\nSolution in Javascript:\",\"targets\":\"function printKParts ( N , K ) { if ( N % K == 0 ) { for ( var i = 1 ; i < K ; i ++ ) document . write ( \\\" \\\" ) ; document . write ( ( N - ( K - 1 ) ) + \\\" \\\" ) ; } else { if ( K == 2 ) { document . write ( \\\" \\\" + \\\" \\\" ) ; return ; } for ( var i = 1 ; i < K - 1 ; i ++ ) document . write ( 1 + \\\" \\\" ) ; document . write ( 2 + \\\" \\\" + ( N - K ) + \\\" \\\" ) ; } } var N = 18 , K = 5 ; printKParts ( N , K ) ;\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soljs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Find the direction from given string | Function to find the final direction ; if count is positive that implies resultant is clockwise direction ; if count is negative that implies resultant is anti - clockwise direction ; Driver code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function findDirection ( $ s ) { $ count = 0 ; $ d = \\\" \\\" ; for ( $ i = 0 ; $ i < strlen ( $ s ) ; $ i ++ ) { if ( $ s [ 0 ] == ' ' ) return null ; if ( $ s [ $ i ] == ' L ' ) $ count -= 1 ; else { if ( $ s [ $ i ] == ' R ' ) $ count += 1 ; } } if ( $ count > 0 ) { if ( $ count % 4 == 0 ) $ d = \\\" N \\\" ; else if ( $ count % 4 == 1 ) $ d = \\\" E \\\" ; else if ( $ count % 4 == 2 ) $ d = \\\" S \\\" ; else if ( $ count % 4 == 3 ) $ d = \\\" W \\\" ; } if ( $ count < 0 ) { if ( $ count % 4 == 0 ) $ d = \\\" N \\\" ; else if ( $ count % 4 == -1 ) $ d = \\\" W \\\" ; else if ( $ count % 4 == -2 ) $ d = \\\" S \\\" ; else if ( $ count % 4 == -3 ) $ d = \\\" E \\\" ; } return $ d ; } $ s = \\\" LLRLRRL \\\" ; echo findDirection ( $ s ) . \\\" \\n \\\" ; $ s = \\\" LL \\\" ; echo findDirection ( $ s ) . \\\" \\n \\\" ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Pair having all other given pairs lying between its minimum and maximum | Java program for the above approach ; Function to find the position of the pair that covers every pair in the array arr [ ] [ ] ; Position to store the index ; Stores the maximum second value ; Stores the minimum first value ; Iterate over the array of pairs ; Update right maximum ; Update left minimum ; Iterate over the array of pairs ; If any pair exists with value { left , right } then store it ; Print the answer ; Driver Code ; Given array of pairs ; Function Call\\\"\\nHow can the above be solved in Java?\",\"targets\":\"import java . util . * ; class GFG { static void position ( int arr [ ] [ ] , int N ) { int pos = - 1 ; int right = Integer . MIN_VALUE ; int left = Integer . MAX_VALUE ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] [ 1 ] > right ) { right = arr [ i ] [ 1 ] ; } if ( arr [ i ] [ 0 ] < left ) { left = arr [ i ] [ 0 ] ; } } for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] [ 0 ] == left && arr [ i ] [ 1 ] == right ) { pos = i + 1 ; } } System . out . print ( pos + \\\"\\n\\\"); } public static void main ( String [ ] args ) { int arr [ ] [ ] = { { 3 , 3 } , { 1 , 3 } , { 2 , 2 } , { 2 , 3 } , { 1 , 2 } } ; int N = arr . length ; position ( arr , N ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejava\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Java-program-level\"}\n" "{\"inputs\":\"\\\"Check if a string can be made equal to another string by swapping or replacement of characters | Function to find if given Strings are same or not ; Base Condition ; Stores frequency of characters of the String str1 and str2 ; Traverse Strings str1 & str2 and store frequencies in a [ ] and b [ ] ; Check if both Strings have same characters or not ; If a character is present in one String and is not in another String , return false ; Sort the array a [ ] and b [ ] ; Check arrays a and b contain the same frequency or not ; If the frequencies are not the same after sorting ; At this point , str1 can be converted to str2 ; Driver Code\\\"\\nHow can the above be solved in JS?\",\"targets\":\"function sameStrings ( str1 , str2 ) { var N = str1 . length ; var M = str2 . length ; if ( N !== M ) { return false ; } var a = new Array ( 256 ) . fill ( 0 ) ; var b = new Array ( 256 ) . fill ( 0 ) ; for ( var j = 0 ; j < N ; j ++ ) { a [ str1 [ j ] . charCodeAt ( 0 ) - \\\" \\\" . charCodeAt ( 0 ) ] ++ ; b [ str2 [ j ] . charCodeAt ( 0 ) - \\\" \\\" . charCodeAt ( 0 ) ] ++ ; } var i = 0 ; while ( i < 256 ) { if ( ( a [ i ] === 0 && b [ i ] === 0 ) || ( a [ i ] !== 0 && b [ i ] !== 0 ) ) { i ++ ; } else { return false ; } } a . sort ( ( x , y ) => x - y ) ; b . sort ( ( x , y ) => x - y ) ; for ( var j = 0 ; j < 256 ; j ++ ) { if ( a [ j ] !== b [ j ] ) return false ; } return true ; } var S1 = \\\" \\\" , S2 = \\\" \\\" ; if ( sameStrings ( S1 , S2 ) ) document . write ( \\\" \\\" + \\\" \\\" ) ; else document . write ( \\\" \\\" + \\\" \\\" ) ;\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovejs\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Javascript-program-level\"}\n" "{\"inputs\":\"\\\"Number of ways to remove a sub | Function to return the number of ways of removing a sub - string from $s such that all the remaining characters are same ; To store the count of prefix and suffix ; Loop to count prefix ; Loop to count suffix ; First and last characters of the string are same ; Otherwise ; Driver Code\\\"\\nHow can the above be solved in PHP?\",\"targets\":\"< ? php function no_of_ways ( $ s ) { $ n = strlen ( $ s ) ; $ count_left = 0 ; $ count_right = 0 ; for ( $ i = 0 ; $ i < $ n ; ++ $ i ) { if ( $ s [ $ i ] == $ s [ 0 ] ) { ++ $ count_left ; } else break ; } for ( $ i = $ n - 1 ; $ i >= 0 ; -- $ i ) { if ( $ s [ $ i ] == $ s [ $ n - 1 ] ) { ++ $ count_right ; } else break ; } if ( $ s [ 0 ] == $ s [ $ n - 1 ] ) return ( ( $ count_left + 1 ) * ( $ count_right + 1 ) ) ; else return ( $ count_left + $ count_right + 1 ) ; } $ s = \\\" geeksforgeeks \\\" ; echo no_of_ways ( $ s ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovephp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Minimum distance between the maximum and minimum element of a given Array | Python3 Program to implement the above approach ; Function to find the minimum distance between the minimum and the maximum element ; Stores the minimum and maximum array element ; Stores the most recently traversed indices of the minimum and the maximum element ; Stores the minimum distance between the minimum and the maximium ; Find the maximum and the minimum element from the given array ; Find the minimum distance ; Check if current element is equal to minimum ; Check if current element is equal to maximum ; If both the minimum and the maximum element has occurred at least once ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"import sys\\ndef minDistance ( a , n ) :\\n\\tmaximum = - 1\\n\\tminimum = sys . maxsize\\n\\tmin_index = - 1\\n\\tmax_index = - 1\\n\\tmin_dist = n + 1\\n\\tfor i in range ( n ) :\\n\\t\\tif ( a [ i ] > maximum ) :\\n\\t\\t\\tmaximum = a [ i ]\\n\\t\\tif ( a [ i ] < minimum ) :\\n\\t\\t\\tminimum = a [ i ]\\n\\tfor i in range ( n ) :\\n\\t\\tif ( a [ i ] == minimum ) :\\n\\t\\t\\tmin_index = i\\n\\t\\tif ( a [ i ] == maximum ) :\\n\\t\\t\\tmax_index = i\\n\\t\\tif ( min_index != - 1 and max_index != - 1 ) :\\n\\t\\t\\tmin_dist = ( min ( min_dist , abs ( min_index - max_index ) ) )\\n\\treturn min_dist\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\ta = [ 3 , 2 , 1 , 2 , 1 , 4 , 5 , 8 , 6 , 7 , 8 , 2 ]\\n\\tn = len ( a )\\n\\tprint ( minDistance ( a , n ) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Largest palindromic number in an array | Function to check if n is palindrome ; Find the appropriate divisor to extract the leading digit ; If first and last digits are not same then return false ; Removing the leading and trailing digits from the number ; Reducing divisor by a factor of 2 as 2 digits are dropped ; Function to find the largest palindromic number ; Sort the array ; If number is palindrome ; If no palindromic number found ; Driver Code ; print required answer\\\"\\nSolution in php:\",\"targets\":\"< ? php function isPalindrome ( $ n ) { $ divisor = 1 ; while ( ( int ) ( $ n \\/ $ divisor ) >= 10 ) $ divisor *= 10 ; while ( $ n != 0 ) { $ leading = ( int ) ( $ n \\/ $ divisor ) ; $ trailing = $ n % 10 ; if ( $ leading != $ trailing ) return false ; $ n = ( int ) ( ( $ n % $ divisor ) \\/ 10 ) ; $ divisor = ( int ) ( $ divisor \\/ 100 ) ; } return true ; } function largestPalindrome ( $ A , $ n ) { sort ( $ A ) ; for ( $ i = $ n - 1 ; $ i >= 0 ; -- $ i ) { if ( isPalindrome ( $ A [ $ i ] ) ) return $ A [ $ i ] ; } return -1 ; } $ A = array ( 1 , 232 , 54545 , 999991 ) ; $ n = sizeof ( $ A ) ; echo largestPalindrome ( $ A , $ n ) ; ? >\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"solphp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"PHP-program-level\"}\n" "{\"inputs\":\"\\\"Print equal sum sets of array ( Partition Problem ) | Set 2 | Python3 program to print equal sum sets of array . ; Function to print equal sum sets of array . ; Finding sum of array elements ; Check sum is even or odd . If odd then array cannot be partitioned . Print - 1 and return . ; Divide sum by 2 to find sum of two possible subsets . ; Boolean DP table to store result of states . dp [ i ] [ j ] = true if there is a subset of elements in first i elements of array that has sum equal to j . ; If number of elements are zero , then no sum can be obtained . ; Sum 0 can be obtained by not selecting any element . ; Fill the DP table in bottom up manner . ; Excluding current element . ; Including current element ; Required sets set1 and set2 . ; If partition is not possible print - 1 and return . ; Start from last element in dp table . ; If current element does not contribute to k , then it belongs to set 2. ; If current element contribute to k then it belongs to set 1. ; Print elements of both the sets . ; Driver Code\\\"\\nSolution in Python:\",\"targets\":\"import numpy as np\\ndef printEqualSumSets ( arr , n ) :\\n\\tsum_array = sum ( arr )\\n\\tif ( sum_array & 1 ) :\\n\\t\\tprint ( \\\" - 1\\\" )\\n\\t\\treturn\\n\\tk = sum_array >> 1\\n\\tdp = np . zeros ( ( n + 1 , k + 1 ) )\\n\\tfor i in range ( 1 , k + 1 ) :\\n\\t\\tdp [ 0 ] [ i ] = False\\n\\tfor i in range ( n + 1 ) :\\n\\t\\tdp [ i ] [ 0 ] = True\\n\\tfor i in range ( 1 , n + 1 ) :\\n\\t\\tfor currSum in range ( 1 , k + 1 ) :\\n\\t\\t\\tdp [ i ] [ currSum ] = dp [ i - 1 ] [ currSum ]\\n\\t\\t\\tif ( arr [ i - 1 ] <= currSum ) :\\n\\t\\t\\t\\tdp [ i ] [ currSum ] = ( dp [ i ] [ currSum ] or dp [ i - 1 ] [ currSum - arr [ i - 1 ] ] )\\n\\tset1 , set2 = [ ] , [ ]\\n\\tif ( not dp [ n ] [ k ] ) :\\n\\t\\tprint ( \\\" - 1\\\" )\\n\\t\\treturn\\n\\ti = n\\n\\tcurrSum = k\\n\\twhile ( i > 0 and currSum >= 0 ) :\\n\\t\\tif ( dp [ i - 1 ] [ currSum ] ) :\\n\\t\\t\\ti -= 1\\n\\t\\t\\tset2 . append ( arr [ i ] )\\n\\t\\telif ( dp [ i - 1 ] [ currSum - arr [ i - 1 ] ] ) :\\n\\t\\t\\ti -= 1\\n\\t\\t\\tcurrSum -= arr [ i ]\\n\\t\\t\\tset1 . append ( arr [ i ] )\\n\\tprint ( \\\" Set ▁ 1 ▁ elements : \\\" , end = \\\" ▁ \\\" )\\n\\tfor i in range ( len ( set1 ) ) :\\n\\t\\tprint ( set1 [ i ] , end = \\\" ▁ \\\" )\\n\\tprint ( \\\" Set 2 elements : \\\" , ▁ end ▁ = ▁ \\\" \\\" )\\n\\tfor i in range ( len ( set2 ) ) :\\n\\t\\tprint ( set2 [ i ] , end = \\\" ▁ \\\" )\\nif __name__ == \\\" _ _ main _ _ \\\" :\\n\\tarr = [ 5 , 5 , 1 , 11 ]\\n\\tn = len ( arr )\\n\\tprintEqualSumSets ( arr , n )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solpy\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Python-program-level\"}\n" "{\"inputs\":\"\\\"Program to convert Centimeters to Pixels | C # program to convert centimeter to pixels ; Function to convert centimeter to pixels ; Driver Code\\\"\\nHow can the above be solved in C-Sharp?\",\"targets\":\"using System ; class GFG { static double Conversion ( double centi ) { double pixels = ( 96 * centi ) \\/ 2.54 ; Console . WriteLine ( pixels ) ; return 0 ; } public static void Main ( ) { double centi = 15 ; Conversion ( centi ) ; } }\",\"language\":\"python\",\"split\":\"validation\",\"template\":\"abovecsharp\",\"dataset\":\"codeparrot\\/xlcost-text-to-code\",\"config\":\"Csharp-program-level\"}\n"