dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int binomialCoeff ( int n , int k ) { int [ ] C = new int [ k + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = Math . Min ( i , k ) ; j > 0 ; j -- ) C [ j ] = C [ j ] + C [ j - 1 ] ; } return C [ k ] ; } static int countArray ( int N , int K ) { return binomialCoeff ( K - 1 , N - 1 ) ; } static public void Main ( ) { int N = 2 , K = 3 ; Console . WriteLine ( countArray ( N , K ) ) ; } }

Index/key variables: j, k
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public class data { public int element ; public int position ; } ; static data findMinElement ( int [ ] arr , int n ) { data result = new data ( ) ; int [ ] prefixSum = new int [ n ] ; int [ ] suffixSum = new int [ n ] ; prefixSum [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { prefixSum [ i ] = prefixSum [ i - 1 ] + arr [ i ] ; } suffixSum [ n - 1 ] = arr [ n - 1 ] ; for ( int i = n - 2 ; i >= 0 ; i -- ) { suffixSum [ i ] = suffixSum [ i + 1 ] + arr [ i ] ; } int min = suffixSum [ 0 ] ; int pos = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( Math . Abs ( suffixSum [ i + 1 ] - prefixSum [ i ] ) < min ) { min = Math . Abs ( suffixSum [ i + 1 ] - prefixSum [ i ] ) ; if ( suffixSum [ i + 1 ] < prefixSum [ i ] ) pos = i + 1 ; else pos = i ; } } result . element = min ; result . position = pos ; return result ; } public static void Main ( String [ ] args ) { int [ ] arr = { 10 , 1 , 2 , 3 , 4 } ; int n = arr . Length ; data values ; values = findMinElement ( arr , n ) ; Console . WriteLine ( " Minimum ▁ element ▁ : ▁ " + values . element + " STRNEWLINE Position ▁ : ▁ " + values . position ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, data
C# program:
using System ; class GFG { static int N = 100 ; public static int count ( int n , int c , int [ ] a , int [ ] b ) { int [ ] need = new int [ N ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i + n ] = a [ i ] ; b [ i + n ] = b [ i ] ; } int s = 0 ; int tank = 0 ; for ( int i = 0 ; i < 2 * n ; i ++ ) { tank += a [ i ] ; tank = Math . Min ( tank , c ) ; tank -= b [ i ] ; if ( tank < 0 ) { tank = 0 ; s = i + 1 ; } } if ( s >= n ) return 0 ; int ans = 1 ; need [ s + n ] = 0 ; for ( int i = 1 ; i < n ; i ++ ) { int id = s + n - i ; need [ id ] = Math . Max ( 0 , need [ id + 1 ] + b [ id ] - Math . Min ( a [ id ] , c ) ) ; if ( need [ id ] == 0 ) ans ++ ; } return ans ; } static void Main ( ) { int n = 3 ; int c = 3 ; int [ ] a = new int [ 6 ] { 3 , 1 , 2 , 0 , 0 , 0 } ; int [ ] b = new int [ 6 ] { 2 , 2 , 2 , 0 , 0 , 0 } ; Console . Write ( count ( n , c , a , b ) + " STRNEWLINE " ) ; } }

Index/key variables: N, i, id
Accumulator variables: ans, i, tank
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Linq ; using System . Collections . Generic ; class GFG { static void printEqualSumSets ( int [ ] arr , int n ) { int i , currSum , sum = 0 ; for ( i = 0 ; i < arr . Length ; i ++ ) sum += arr [ i ] ; if ( ( sum & 1 ) == 1 ) { Console . Write ( " - 1" ) ; return ; } int k = sum >> 1 ; bool [ , ] dp = new bool [ n + 1 , k + 1 ] ; for ( i = 1 ; i <= k ; i ++ ) dp [ 0 , i ] = false ; for ( i = 0 ; i <= n ; i ++ ) dp [ i , 0 ] = true ; for ( i = 1 ; i <= n ; i ++ ) { for ( currSum = 1 ; currSum <= k ; currSum ++ ) { dp [ i , currSum ] = dp [ i - 1 , currSum ] ; if ( arr [ i - 1 ] <= currSum ) dp [ i , currSum ] = dp [ i , currSum ] | dp [ i - 1 , currSum - arr [ i - 1 ] ] ; } } List < int > set1 = new List < int > ( ) ; List < int > set2 = new List < int > ( ) ; if ( ! dp [ n , k ] ) { Console . Write ( " - 1 STRNEWLINE " ) ; return ; } i = n ; currSum = k ; while ( i > 0 && currSum >= 0 ) { if ( dp [ i - 1 , currSum ] ) { i -- ; set2 . Add ( arr [ i ] ) ; } else if ( dp [ i - 1 , currSum - arr [ i - 1 ] ] ) { i -- ; currSum -= arr [ i ] ; set1 . Add ( arr [ i ] ) ; } } Console . Write ( " Set ▁ 1 ▁ elements : ▁ " ) ; for ( i = 0 ; i < set1 . Count ; i ++ ) Console . Write ( set1 [ i ] + " ▁ " ) ; Console . Write ( " STRNEWLINE Set ▁ 2 ▁ elements : ▁ " ) ; for ( i = 0 ; i < set2 . Count ; i ++ ) Console . Write ( set2 [ i ] + " ▁ " ) ; } static void Main ( ) { int [ ] arr = { 5 , 5 , 1 , 11 } ; int n = arr . Length ; printEqualSumSets ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: currSum, i, sum
Iterator variables: currSum, i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static double largestSumOfAverages ( int [ ] A , int K ) { int n = A . Length ; double [ ] pre_sum = new double [ n + 1 ] ; pre_sum [ 0 ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) pre_sum [ i + 1 ] = pre_sum [ i ] + A [ i ] ; double [ ] dp = new double [ n ] ; for ( int i = 0 ; i < n ; i ++ ) dp [ i ] = ( pre_sum [ n ] - pre_sum [ i ] ) / ( n - i ) ; for ( int k = 0 ; k < K - 1 ; k ++ ) for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) dp [ i ] = Math . Max ( dp [ i ] , ( pre_sum [ j ] - pre_sum [ i ] ) / ( j - i ) + dp [ j ] ) ; return dp [ 0 ] ; } public static void Main ( String [ ] args ) { int [ ] A = { 9 , 1 , 2 , 3 , 9 } ; Console . WriteLine ( largestSumOfAverages ( A , K ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int N = 105 ; static int M = 1001 ; static int INF = - 1111111111 ; static int maxSum ( int [ ] [ ] arr ) { int [ , ] dp = new int [ N , M ] ; int [ ] current_arr = new int [ M ] ; int [ ] maxsum = new int [ M ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) dp [ i , j ] = - 1 ; } current_arr [ 0 ] = 0 ; dp [ 0 , 0 ] = 0 ; for ( int i = 1 ; i <= 5 ; i ++ ) { int len = arr [ i - 1 ] [ 0 ] ; for ( int j = 1 ; j <= len ; j ++ ) { current_arr [ j ] = arr [ i - 1 ] [ j ] ; current_arr [ j ] += current_arr [ j - 1 ] ; maxsum [ j ] = INF ; } for ( int j = 1 ; j <= len && j <= 6 ; j ++ ) for ( int k = 1 ; k <= len ; k ++ ) if ( j + k - 1 <= len ) maxsum [ j ] = Math . Max ( maxsum [ j ] , current_arr [ j + k - 1 ] - current_arr [ k - 1 ] ) ; for ( int j = 0 ; j <= 6 ; j ++ ) dp [ i , j ] = dp [ i - 1 , j ] ; for ( int j = 1 ; j <= 6 ; j ++ ) for ( int cur = 1 ; cur <= j && cur <= len ; cur ++ ) dp [ i , j ] = Math . Max ( dp [ i , j ] , dp [ i - 1 , j - cur ] + maxsum [ cur ] ) ; } int ans = 0 ; for ( int i = 0 ; i <= 6 ; i ++ ) ans = Math . Max ( ans , dp [ 5 , i ] ) ; return ans ; } static void Main ( ) { int [ ] [ ] arr = new int [ ] [ ] { new int [ ] { 3 , 2 , 3 , 5 } , new int [ ] { 2 , 7 , - 1 } , new int [ ] { 2 , 8 , 10 } , new int [ ] { 4 , 5 , 2 , 6 , 1 } , new int [ ] { 3 , 2 , 3 , - 2 } } ; Console . Write ( " Maximum ▁ sum ▁ can ▁ be ▁ " + " obtained ▁ is ▁ : ▁ " + maxSum ( arr ) + " STRNEWLINE " ) ; } }

Index/key variables: M, cur, j
Accumulator variables: cur, i, j, k
Iterator variables: cur, i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMaxVal ( int [ ] arr , int n , int num , int maxLimit ) { int ind ; int val ; int [ , ] dp = new int [ n , maxLimit + 1 ] ; for ( ind = 0 ; ind < n ; ind ++ ) { for ( val = 0 ; val <= maxLimit ; val ++ ) { if ( ind == 0 ) { if ( num - arr [ ind ] == val num + arr [ ind ] == val ) { dp [ ind , val ] = 1 ; } else { dp [ ind , val ] = 0 ; } } else { if ( val - arr [ ind ] >= 0 && val + arr [ ind ] <= maxLimit ) { if ( dp [ ind - 1 , val - arr [ ind ] ] == 1 dp [ ind - 1 , val + arr [ ind ] ] == 1 ) dp [ ind , val ] = 1 ; } else if ( val - arr [ ind ] >= 0 ) { dp [ ind , val ] = dp [ ind - 1 , val - arr [ ind ] ] ; } else if ( val + arr [ ind ] <= maxLimit ) { dp [ ind , val ] = dp [ ind - 1 , val + arr [ ind ] ] ; } else { dp [ ind , val ] = 0 ; } } } } for ( val = maxLimit ; val >= 0 ; val -- ) { if ( dp [ n - 1 , val ] == 1 ) { return val ; } } return - 1 ; } static void Main ( ) { int num = 1 ; int [ ] arr = new int [ ] { 3 , 10 , 6 , 4 , 5 } ; int n = arr . Length ; int maxLimit = 15 ; Console . Write ( findMaxVal ( arr , n , num , maxLimit ) ) ; } }

Index/key variables: ind
Accumulator variables: ind, val
Iterator variables: ind, val
Class/struct names: GFG
C# program:
using System ; class GFG { public static int gen ( int n ) { if ( n == 0 ) return 0 ; else if ( n == 1 ) return 1 ; else if ( n % 2 == 0 ) return 4 * gen ( n / 2 ) ; else if ( n % 2 == 1 ) return 4 * gen ( n / 2 ) + 1 ; return 0 ; } public static void moserDeBruijn ( int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( gen ( i ) + " ▁ " ) ; Console . WriteLine ( ) ; } public static void Main ( ) { int n = 15 ; Console . WriteLine ( " First ▁ " + n + " ▁ terms ▁ of ▁ " + " Moser - de ▁ Bruijn ▁ Sequence ▁ : ▁ " ) ; moserDeBruijn ( n ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; using System . Linq ; class GFG { static int minSumPath ( ref List < List < int > > A ) { int [ ] memo = new int [ A . Count ] ; int n = A . Count - 1 ; for ( int i = 0 ; i < A [ n ] . Count ; i ++ ) memo [ i ] = A [ n ] [ i ] ; for ( int i = A . Count - 2 ; i >= 0 ; i -- ) for ( int j = 0 ; j < A [ i + 1 ] . Count - 1 ; j ++ ) memo [ j ] = A [ i ] [ j ] + ( int ) Math . Min ( memo [ j ] , memo [ j + 1 ] ) ; return memo [ 0 ] ; } public static void Main ( ) { List < List < int > > A = new List < List < int > > ( ) ; A . Add ( new List < int > { 2 } ) ; A . Add ( new List < int > { 3 , 9 } ) ; A . Add ( new List < int > { 1 , 6 , 7 } ) ; Console . WriteLine ( minSumPath ( ref A ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
static bool isPossible ( int index , int sum ) { if ( index == n ) { if ( ( sum % M ) == 0 ) return true ; return false ; } bool placeAdd = isPossible ( index + 1 , sum + arr [ index ] ) ; bool placeMinus = isPossible ( index + 1 , sum - arr [ index ] ) ; if ( placeAdd placeMinus ) return true ; return false ; }

Index/key variables: index
C# program:
using System ; class GFG { static int MAX = 100 ; static int [ , ] dp = new int [ MAX , MAX ] ; static int countRemovals ( int [ ] a , int i , int j , int k ) { if ( i >= j ) return 0 ; else if ( ( a [ j ] - a [ i ] ) <= k ) return 0 ; else if ( dp [ i , j ] != - 1 ) return dp [ i , j ] ; else if ( ( a [ j ] - a [ i ] ) > k ) { dp [ i , j ] = 1 + Math . Min ( countRemovals ( a , i + 1 , j , k ) , countRemovals ( a , i , j - 1 , k ) ) ; } return dp [ i , j ] ; } static int removals ( int [ ] a , int n , int k ) { Array . Sort ( a ) ; for ( int i = 0 ; i < MAX ; i ++ ) { for ( int j = 0 ; j < MAX ; j ++ ) dp [ i , j ] = - 1 ; } if ( n == 1 ) return 0 ; else return countRemovals ( a , 0 , n - 1 , k ) ; } static void Main ( ) { int [ ] a = new int [ ] { 1 , 3 , 4 , 9 , 10 , 11 , 12 , 17 , 20 } ; int n = a . Length ; int k = 4 ; Console . Write ( removals ( a , n , k ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int findInd ( int key , int i , int n , int k , int [ ] arr ) { int start , end , mid , ind = - 1 ; start = i + 1 ; end = n - 1 ; while ( start < end ) { mid = start + ( end - start ) / 2 ; if ( arr [ mid ] - key <= k ) { ind = mid ; start = mid + 1 ; } else { end = mid ; } } return ind ; } static int removals ( int [ ] arr , int n , int k ) { int i , j , ans = n - 1 ; Array . Sort ( arr ) ; for ( i = 0 ; i < n ; i ++ ) { j = findInd ( arr [ i ] , i , n , k , arr ) ; if ( j != - 1 ) { ans = Math . Min ( ans , n - ( j - i + 1 ) ) ; } } return ans ; } static void Main ( ) { int [ ] a = { 1 , 3 , 4 , 9 , 10 , 11 , 12 , 17 , 20 } ; int n = a . Length ; int k = 4 ; Console . Write ( removals ( a , n , k ) ) ; } }

Index/key variables: i, mid
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countPairs ( int [ ] a , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) if ( ( a [ i ] & a [ j ] ) == 0 ) count += 2 ; } return count ; } public static void Main ( ) { int [ ] a = { 3 , 4 , 2 } ; int n = a . Length ; Console . Write ( countPairs ( a , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int N = 15 ; static int countPairs ( int [ ] a , int n ) { Dictionary < int , int > hash = new Dictionary < int , int > ( ) ; int [ , ] dp = new int [ 1 << N , N + 1 ] ; for ( int i = 0 ; i < n ; ++ i ) { if ( hash . ContainsKey ( a [ i ] ) ) { hash [ a [ i ] ] += 1 ; } else { hash . Add ( a [ i ] , 1 ) ; } } for ( int mask = 0 ; mask < ( 1 << N ) ; ++ mask ) { if ( ( mask & 1 ) != 0 ) { if ( hash . ContainsKey ( mask ) ) { dp [ mask , 0 ] = hash [ mask ] ; } if ( hash . ContainsKey ( mask ^ 1 ) ) { dp [ mask , 0 ] += hash [ mask ^ 1 ] ; } } else { if ( hash . ContainsKey ( mask ) ) { dp [ mask , 0 ] = hash [ mask ] ; } } for ( int i = 1 ; i <= N ; ++ i ) { if ( ( mask & ( 1 << i ) ) != 0 ) { dp [ mask , i ] = dp [ mask , i - 1 ] + dp [ mask ^ ( 1 << i ) , i - 1 ] ; } else { dp [ mask , i ] = dp [ mask , i - 1 ] ; } } } int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ans += dp [ ( ( 1 << N ) - 1 ) ^ a [ i ] , N ] ; } return ans ; } static void Main ( ) { int [ ] a = { 5 , 4 , 1 , 6 } ; int n = a . Length ; Console . WriteLine ( countPairs ( a , n ) ) ; } }

Index/key variables: i, mask
Accumulator variables: ans, i
Iterator variables: i, mask
Class/struct names: GFG
C# program:
using System ; class GFG { static long [ , ] dp = new long [ 1000 , 1000 ] ; static long sum ( int [ ] a , int i , int j ) { long ans = 0 ; for ( int m = i ; m <= j ; m ++ ) ans = ( ans + a [ m ] ) % 100 ; return ans ; } static long solve ( int [ ] a , int i , int j ) { if ( i == j ) return 0 ; if ( dp [ i , j ] != - 1 ) return dp [ i , j ] ; dp [ i , j ] = 100000000 ; for ( int k = i ; k < j ; k ++ ) { dp [ i , j ] = Math . Min ( dp [ i , j ] , ( solve ( a , i , k ) + solve ( a , k + 1 , j ) + ( sum ( a , i , k ) * sum ( a , k + 1 , j ) ) ) ) ; } return dp [ i , j ] ; } static void initialize ( int n ) { for ( int i = 0 ; i <= n ; i ++ ) for ( int j = 0 ; j <= n ; j ++ ) dp [ i , j ] = - 1 ; } public static void Main ( ) { int [ ] a = { 40 , 60 , 20 } ; int n = a . Length ; initialize ( n ) ; Console . WriteLine ( solve ( a , 0 , n - 1 ) ) ; } }

Index/key variables: m
Accumulator variables: i, j, k, m
Iterator variables: i, j, k, m
Class/struct names: GFG
C# program:
using System ; class GFG { static void reverseFibonacci ( int n ) { int [ ] a = new int [ n ] ; a [ 0 ] = 0 ; a [ 1 ] = 1 ; for ( int i = 2 ; i < n ; i ++ ) { a [ i ] = a [ i - 2 ] + a [ i - 1 ] ; } for ( int i = n - 1 ; i >= 0 ; i -- ) { Console . Write ( a [ i ] + " ▁ " ) ; } } public static void Main ( ) { int n = 5 ; reverseFibonacci ( n ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool check ( string s1 , string s2 ) { int n = s1 . Length ; int m = s2 . Length ; bool [ , ] dp = new bool [ n + 1 , m + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= m ; j ++ ) { dp [ i , j ] = false ; } } dp [ 0 , 0 ] = true ; for ( int i = 0 ; i < s1 . Length ; i ++ ) { for ( int j = 0 ; j <= s2 . Length ; j ++ ) { if ( dp [ i , j ] ) { if ( j < s2 . Length && ( Char . ToUpper ( s1 [ i ] ) == s2 [ j ] ) ) dp [ i + 1 , j + 1 ] = true ; if ( ! Char . IsUpper ( s1 [ i ] ) ) dp [ i + 1 , j ] = true ; } } } return ( dp [ n , m ] ) ; } public static void Main ( ) { string s1 = " daBcd " ; string s2 = " ABC " ; if ( check ( s1 , s2 ) ) Console . Write ( " YES " ) ; else Console . Write ( " NO " ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static float find_prob ( int N , float P ) { double [ ] dp = new double [ N + 1 ] ; dp [ 0 ] = 1 ; dp [ 1 ] = 0 ; dp [ 2 ] = P ; dp [ 3 ] = 1 - P ; for ( int i = 4 ; i <= N ; ++ i ) dp [ i ] = ( P ) * dp [ i - 2 ] + ( 1 - P ) * dp [ i - 3 ] ; return ( ( float ) ( dp [ N ] ) ) ; } public static void Main ( ) { int n = 5 ; float p = 0.2f ; Console . WriteLine ( find_prob ( n , p ) ) ; } }

Index/key variables: N, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int getLevenstein ( String input ) { String revInput = Reverse ( input ) ; int n = input . Length ; int [ , ] dp = new int [ n + 1 , n + 1 ] ; for ( int i = 0 ; i <= n ; ++ i ) { dp [ 0 , i ] = i ; dp [ i , 0 ] = i ; } for ( int i = 1 ; i <= n ; ++ i ) { for ( int j = 1 ; j <= n ; ++ j ) { if ( input [ i - 1 ] == revInput [ j - 1 ] ) dp [ i , j ] = dp [ i - 1 , j - 1 ] ; else dp [ i , j ] = 1 + Math . Min ( dp [ i - 1 , j ] , dp [ i , j - 1 ] ) ; } } int res = int . MaxValue ; for ( int i = n , j = 0 ; i >= 0 ; i -- , j ++ ) { res = Math . Min ( res , dp [ i , j ] ) ; if ( i < n ) res = Math . Min ( res , dp [ i + 1 , j ] ) ; if ( i > 0 ) res = Math . Min ( res , dp [ i - 1 , j ] ) ; } return res ; } static String Reverse ( String input ) { char [ ] a = input . ToCharArray ( ) ; int l , r = a . Length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { char temp = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = temp ; } return String . Join ( " " , a ) ; } public static void Main ( String [ ] args ) { String input = " myfirstgeekarticle " ; Console . WriteLine ( getLevenstein ( input ) ) ; } }

Index/key variables: l, r
Accumulator variables: i, j, l, r
Iterator variables: i, j, l
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] dp = new int [ MAXN ] ; static int [ , ] nck = new int [ MAXN , MAXN ] ; static int [ ] log2 = new int [ MAXN ] ; public static int choose ( int n , int k ) { if ( k > n ) return 0 ; if ( n <= 1 ) return 1 ; if ( k == 0 ) return 1 ; if ( nck [ n , k ] != - 1 ) return nck [ n , k ] ; int answer = choose ( n - 1 , k - 1 ) + choose ( n - 1 , k ) ; nck [ n , k ] = answer ; return answer ; } public static int getLeft ( int n ) { if ( n == 1 ) return 0 ; int h = log2 [ n ] ; int last = n - ( ( 1 << h ) - 1 ) ; if ( last >= ( numh / 2 ) ) else return ( 1 << h ) - 1 - ( ( numh / 2 ) - last ) ; } public static int numberOfHeaps ( int n ) { if ( n <= 1 ) return 1 ; if ( dp [ n ] != - 1 ) return dp [ n ] ; int left = getLeft ( n ) ; int ans = ( choose ( n - 1 , left ) * numberOfHeaps ( left ) ) * ( numberOfHeaps ( n - 1 - left ) ) ; dp [ n ] = ans ; return ans ; } public static int solve ( int n ) { for ( int i = 0 ; i <= n ; i ++ ) dp [ i ] = - 1 ; for ( int i = 0 ; i <= n ; i ++ ) for ( int j = 0 ; j <= n ; j ++ ) nck [ i , j ] = - 1 ; int currLog2 = - 1 ; int currPower2 = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( currPower2 == i ) { currLog2 ++ ; currPower2 *= 2 ; } log2 [ i ] = currLog2 ; } return numberOfHeaps ( n ) ; } static void Main ( ) { int n = 10 ; Console . Write ( solve ( n ) ) ; } }

Index/key variables: MAXN, i, n
Accumulator variables: currLog2, currPower2, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int N = 5 ; static void printHosoya ( int n ) { int [ , ] dp = new int [ N , N ] ; dp [ 0 , 0 ] = dp [ 1 , 0 ] = 1 ; dp [ 1 , 1 ] = 1 ; for ( int i = 2 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i > j ) dp [ i , j ] = dp [ i - 1 , j ] + dp [ i - 2 , j ] ; else dp [ i , j ] = dp [ i - 1 , j - 1 ] + dp [ i - 2 , j - 2 ] ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j <= i ; j ++ ) Console . Write ( dp [ i , j ] + " ▁ " ) ; Console . WriteLine ( " " ) ; } } public static void Main ( ) { int n = 5 ; printHosoya ( n ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int numberofways ( int n , int m ) { int [ , ] dp = new int [ n + 2 , n + 2 ] ; dp [ 0 , n + 1 ] = 1 ; for ( int k = n ; k >= m ; k -- ) { for ( int i = 0 ; i <= n ; i ++ ) { dp [ i , k ] = dp [ i , k + 1 ] ; if ( i - k >= 0 ) dp [ i , k ] = ( dp [ i , k ] + dp [ i - k , k ] ) ; } } return dp [ n , m ] ; } public static void Main ( ) { int n = 3 , m = 1 ; Console . WriteLine ( numberofways ( n , m ) ) ; } }

Accumulator variables: i, k
Iterator variables: i, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int zigzag ( int n , int k ) { if ( n == 0 && k == 0 ) return 1 ; if ( k == 0 ) return 0 ; return zigzag ( n , k - 1 ) + zigzag ( n - 1 , n - k ) ; } public static void Main ( ) { int n = 4 , k = 3 ; Console . WriteLine ( zigzag ( n , k ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class Eulerian { public static int eulerian ( int n , int m ) { int [ , ] dp = new int [ n + 1 , m + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= m ; j ++ ) { if ( i > j ) { if ( j == 0 ) dp [ i , j ] = 1 ; else dp [ i , j ] = ( ( i - j ) * dp [ i - 1 , j - 1 ] ) + ( ( j + 1 ) * dp [ i - 1 , j ] ) ; } } } return dp [ n , m ] ; } public static void Main ( ) { int n = 3 , m = 1 ; Console . WriteLine ( eulerian ( n , m ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: Eulerian
C# program:
using System ; public class GfG { public static int dealnnoy ( int n , int m ) { if ( m == 0 n == 0 ) return 1 ; return dealnnoy ( m - 1 , n ) + dealnnoy ( m - 1 , n - 1 ) + dealnnoy ( m , n - 1 ) ; } public static void Main ( ) { int n = 3 , m = 4 ; Console . WriteLine ( dealnnoy ( n , m ) ) ; } }

Class/struct names: GfG
C# program:
using System ; class GFG { static int dealnnoy ( int n , int m ) { int [ , ] dp = new int [ m + 1 , n + 1 ] ; for ( int i = 0 ; i <= m ; i ++ ) dp [ i , 0 ] = 1 ; for ( int i = 0 ; i < m ; i ++ ) dp [ 0 , i ] = 1 ; for ( int i = 1 ; i <= m ; i ++ ) for ( int j = 1 ; j <= n ; j ++ ) dp [ i , j ] = dp [ i - 1 , j ] + dp [ i - 1 , j - 1 ] + dp [ i , j - 1 ] ; return dp [ m , n ] ; } public static void Main ( ) { int n = 3 , m = 4 ; Console . WriteLine ( dealnnoy ( n , m ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class Longest { public static void longestAlternating ( int [ ] arr , int n ) { int [ ] count = new int [ n ] ; count [ n - 1 ] = 1 ; for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( arr [ i ] * arr [ i + 1 ] < 0 ) count [ i ] = count [ i + 1 ] + 1 ; else count [ i ] = 1 ; } for ( int i = 0 ; i < n ; i ++ ) Console . Write ( count [ i ] + " ▁ " ) ; } public static void Main ( ) { int [ ] a = { - 5 , - 1 , - 1 , 2 , - 2 , - 3 } ; int n = 6 ; longestAlternating ( a , n ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: Longest
C# program:
using System ; class GFG { static int maxDP ( int n ) { int [ ] res = new int [ n + 1 ] ; res [ 0 ] = 0 ; res [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) res [ i ] = Math . Max ( i , ( res [ i / 2 ] + res [ i / 3 ] + res [ i / 4 ] + res [ i / 5 ] ) ) ; return res [ n ] ; } public static void Main ( ) { int n = 60 ; Console . WriteLine ( " MaxSum ▁ = ▁ " + maxDP ( n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG