dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static int height ( int s , List < int > [ ] adj , int [ ] visited ) { visited [ s ] = 1 ; int h = 0 ; foreach ( int child in adj [ s ] ) { if ( visited [ child ] == 0 ) { h = Math . Max ( h , 1 + height ( child , adj , visited ) ) ; } } return h ; } static int minimumGroups ( List < int > [ ] adj , int N ) { int [ ] visited = new int [ N + 1 ] ; int groups = int . MinValue ; for ( int i = 1 ; i <= N ; i ++ ) { if ( visited [ i ] == 0 ) { int comHeight ; comHeight = height ( i , adj , visited ) ; groups = Math . Max ( groups , comHeight ) ; } } return groups ; } static void addEdge ( List < int > [ ] adj , int u , int v ) { adj [ u ] . Add ( v ) ; adj [ v ] . Add ( u ) ; } public static void Main ( String [ ] args ) { int N = 5 ; List < int > [ ] adj = new List < int > [ N + 1 ] ; for ( int i = 0 ; i < N + 1 ; i ++ ) adj [ i ] = new List < int > ( ) ; addEdge ( adj , 1 , 2 ) ; addEdge ( adj , 3 , 2 ) ; addEdge ( adj , 4 , 3 ) ; Console . Write ( minimumGroups ( adj , N ) ) ; } }

Index/key variables: child, i, s, u, v
Accumulator variables: i
Iterator variables: child, i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int ans ; static void subsetSum ( List < int > c ) { int L = c . Count ; int mul = ( int ) Math . Pow ( 2 , L - 1 ) ; for ( int i = 0 ; i < c . Count ; i ++ ) ans += c [ i ] * mul ; } static void subsetGen ( int [ ] arr , int i , int n , List < int > c ) { if ( i == n ) { subsetSum ( c ) ; return ; } subsetGen ( arr , i + 1 , n , c ) ; c . Add ( arr [ i ] ) ; subsetGen ( arr , i + 1 , n , c ) ; c . RemoveAt ( 0 ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 1 } ; int n = arr . Length ; List < int > c = new List < int > ( ) ; subsetGen ( arr , 0 , n , c ) ; Console . WriteLine ( ans ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int getMaxValue ( int [ ] arr , int arr_size ) { int i , first , second ; if ( arr_size < 2 ) { return 0 ; } first = second = int . MinValue ; 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 . MinValue ) { return 0 ; } else { return second ; } } public static void Main ( ) { int [ ] arr = { 4 , 5 , 1 , 8 } ; int n = arr . Length ; Console . Write ( getMaxValue ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maximumResult ( int a , int b , int c ) { int countOfNegative = 0 ; int sum = a + b + c ; int product = a * b * c ; int largest = ( a > b ) ? ( ( a > c ) ? a : c ) : ( ( b > c ) ? b : c ) ; int smallest = ( a < b ) ? ( ( a < c ) ? a : c ) : ( ( b < c ) ? b : c ) ; if ( a < 0 ) countOfNegative ++ ; if ( b < 0 ) countOfNegative ++ ; if ( c < 0 ) countOfNegative ++ ; switch ( countOfNegative ) { case 0 : return ( sum - largest ) * largest ; case 1 : return ( product / smallest ) + smallest ; case 2 : return ( product / largest ) + largest ; case 3 : return ( sum - smallest ) * smallest ; } return - 1 ; } static void Main ( ) { int a = - 2 , b = - 1 , c = - 4 ; Console . WriteLine ( maximumResult ( a , b , c ) ) ; } }

Accumulator variables: countOfNegative
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; using System . Collections ; using System . Linq ; class GFG { static int check ( int n , List < int > marks ) { int x = marks . Max ( ) ; int bonus = 100 - x ; int c = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( marks [ i ] + bonus >= 50 ) c += 1 ; } return c ; } public static void Main ( ) { int n = 5 ; List < int > marks = new List < int > ( new int [ ] { 0 , 21 , 83 , 45 , 64 } ) ; Console . WriteLine ( check ( n , marks ) ) ; } }

Index/key variables: i
Accumulator variables: c, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int find_sum ( int n , int k ) { int total_sum = ( n * ( n + 1 ) ) / 2 ; int power = k ; while ( power <= n ) { total_sum -= power ; power *= k ; } return total_sum ; } public static void Main ( ) { int n = 11 , k = 2 ; Console . WriteLine ( find_sum ( n , k ) ) ; } }

Accumulator variables: power, total_sum
Class/struct names: GFG
C# program:
using System ; public class Solution { public const int MAX = 10000 ; public static int [ ] hashTable = new int [ MAX ] ; public static int minOperations ( int [ ] arr , int n ) { Array . Sort ( arr ) ; for ( int i = 0 ; i < n ; i ++ ) { hashTable [ arr [ i ] ] ++ ; } int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( hashTable [ arr [ i ] ] != 0 ) { for ( int j = i ; j < n ; j ++ ) { if ( arr [ j ] % arr [ i ] == 0 ) { hashTable [ arr [ j ] ] = 0 ; } } res ++ ; } } return res ; } public static void Main ( string [ ] args ) { int [ ] arr = new int [ ] { 4 , 6 , 2 , 8 , 7 , 21 , 24 , 49 , 44 } ; int n = arr . Length ; Console . Write ( minOperations ( arr , n ) ) ; } }

Index/key variables: MAX, i, j
Accumulator variables: i, j, res
Iterator variables: i, j
Class/struct names: Solution
C# program:
using System ; class GFG { static bool ifPossible ( int [ ] arr , int n ) { int [ ] cp = new int [ n ] ; Array . Copy ( arr , cp , n ) ; Array . Sort ( cp ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! ( arr [ i ] == cp [ i ] ) && ! ( arr [ n - 1 - i ] == cp [ i ] ) ) return false ; } return true ; } public static void Main ( ) { int [ ] arr = new int [ ] { 1 , 7 , 6 , 4 , 5 , 3 , 2 , 8 } ; int n = arr . Length ; if ( ifPossible ( arr , n ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class Process { public Process ( int pid , int bt , int art ) { this . pid = pid ; this . bt = bt ; this . art = art ; } } public class GFG { static void findWaitingTime ( Process [ ] proc , int n , int [ ] wt ) { int [ ] rt = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) rt [ i ] = proc [ i ] . bt ; int complete = 0 , t = 0 , minm = int . MaxValue ; int shortest = 0 , finish_time ; bool check = false ; while ( complete != n ) { for ( int j = 0 ; j < n ; j ++ ) { if ( ( proc [ j ] . art <= t ) && ( rt [ j ] < minm ) && rt [ j ] > 0 ) { minm = rt [ j ] ; shortest = j ; check = true ; } } if ( check == false ) { t ++ ; continue ; } rt [ shortest ] -- ; minm = rt [ shortest ] ; if ( minm == 0 ) minm = int . MaxValue ; if ( rt [ shortest ] == 0 ) { complete ++ ; check = false ; finish_time = t + 1 ; wt [ shortest ] = finish_time - proc [ shortest ] . bt - proc [ shortest ] . art ; if ( wt [ shortest ] < 0 ) wt [ shortest ] = 0 ; } t ++ ; } } static void findTurnAroundTime ( Process [ ] proc , int n , int [ ] wt , int [ ] tat ) { for ( int i = 0 ; i < n ; i ++ ) tat [ i ] = proc [ i ] . bt + wt [ i ] ; } static void findavgTime ( Process [ ] proc , int n ) { int [ ] wt = new int [ n ] ; int [ ] tat = new int [ n ] ; int total_wt = 0 , total_tat = 0 ; findWaitingTime ( proc , n , wt ) ; findTurnAroundTime ( proc , n , wt , tat ) ; Console . WriteLine ( " Processes ▁ " + " ▁ Burst ▁ time ▁ " + " ▁ Waiting ▁ time ▁ " + " ▁ Turn ▁ around ▁ time " ) ; for ( int i = 0 ; i < n ; i ++ ) { total_wt = total_wt + wt [ i ] ; total_tat = total_tat + tat [ i ] ; Console . WriteLine ( " ▁ " + proc [ i ] . pid + " TABSYMBOL TABSYMBOL " + proc [ i ] . bt + " TABSYMBOL TABSYMBOL ▁ " + wt [ i ] + " TABSYMBOL TABSYMBOL " + tat [ i ] ) ; } Console . WriteLine ( " Average ▁ waiting ▁ time ▁ = ▁ " + ( float ) total_wt / ( float ) n ) ; Console . WriteLine ( " Average ▁ turn ▁ around ▁ time ▁ = ▁ " + ( float ) total_tat / ( float ) n ) ; } public static void Main ( String [ ] args ) { Process [ ] proc = { new Process ( 1 , 6 , 1 ) , new Process ( 2 , 8 , 1 ) , new Process ( 3 , 7 , 2 ) , new Process ( 4 , 3 , 3 ) } ; findavgTime ( proc , proc . Length ) ; } }

Index/key variables: i, j, n, shortest
Accumulator variables: complete, i, j, t
Iterator variables: i, j
Boolean variables: check
Class/struct names: GFG, Process
C# program:
using System ; class GFG { static int MAX = 100001 ; static int minimumDeletions ( int [ ] A , int N ) { int [ , ] dp = new int [ N , MAX ] ; for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < MAX ; j ++ ) dp [ i , j ] = 0 ; for ( int i = 0 ; i < N ; i ++ ) { dp [ i , 0 ] = 1 ; for ( int j = i - 1 ; j >= 0 ; j -- ) { if ( A [ i ] >= A [ j ] ) { int diff = A [ i ] - A [ j ] ; for ( int k = 0 ; k <= diff ; k ++ ) { dp [ i , diff ] = Math . Max ( dp [ i , diff ] , dp [ j , k ] + 1 ) ; } } } } int maxSetSize = - 1 ; for ( int i = 0 ; i < MAX ; i ++ ) maxSetSize = Math . Max ( maxSetSize , dp [ N - 1 , i ] ) ; return N - maxSetSize ; } public static void Main ( ) { int [ ] A = { 1 , 4 , 5 , 7 , 20 , 21 } ; int N = A . Length ; Console . Write ( minimumDeletions ( A , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ , ] dp = new int [ 100 + 5 , 900 + 5 ] ; static int mod = 10000007 ; public static int countNumbers ( int n , int x , int y , int sum ) { for ( int i = 0 ; i < dp . GetLength ( 0 ) ; i ++ ) { for ( int j = 0 ; j < dp . GetLength ( 1 ) ; j ++ ) { dp [ i , j ] = - 1 ; } } if ( n == 0 ) { return check ( sum , x , y ) ; } if ( dp [ n , sum ] != - 1 ) { return dp [ n , sum ] % mod ; } int option1 = countNumbers ( n - 1 , x , y , sum + x ) % mod ; int option2 = countNumbers ( n - 1 , x , y , sum + y ) % mod ; return dp [ n , sum ] = ( option1 + option2 ) % mod ; } public static int check ( int sum , int x , int y ) { while ( sum > 0 ) { int ln = sum % 10 ; if ( ln != x && ln != y ) { return 0 ; } sum /= 10 ; } return 1 ; } public static void Main ( String [ ] args ) { int N = 3 , X = 1 , Y = 5 ; Console . WriteLine ( countNumbers ( N , X , Y , 0 ) % mod ) ; } }

Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static int solve ( int [ , ] a , String s , int n , int prev , int mask , int [ , ] dp ) { if ( mask == 0 ) return 0 ; if ( dp [ mask , prev + 1 ] != - 1 ) return dp [ mask , prev + 1 ] ; int ans = 10000 ; for ( int i = 0 ; i < s . Length ; i ++ ) { int id = s [ i ] - ' a ' ; 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 ; } public static bool check ( int mask , int i ) { int c = ( mask & ( 1 << i ) ) ; return c != 0 ; } static void generatePermutation ( int mask , int n , int [ , ] a , String s ) { int [ , ] dp = new int [ ( 1 << n ) + 5 , n + 5 ] ; for ( int i = 0 ; i < ( 1 << n ) + 5 ; i ++ ) for ( int j = 0 ; j < n + 5 ; j ++ ) dp [ i , j ] = - 1 ; for ( int i = 0 ; i < s . Length ; i ++ ) { int id = s [ i ] - ' a ' ; mask |= ( 1 << id ) ; } Console . WriteLine ( solve ( a , s , n , - 1 , mask , dp ) ) ; } public static void Main ( String [ ] args ) { int N = 5 ; String str = " abcde " ; int [ , ] 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 ) ; } }

Index/key variables: i
Accumulator variables: i, j, mask
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int inf = 10000000 ; public static int minCost ( int [ ] a , int i , int j , int k , int [ ] prefix , int [ , ] dp ) { if ( i >= j ) return 0 ; if ( dp [ i , j ] != - 1 ) return dp [ i , j ] ; int best_cost = inf ; for ( int pos = i ; pos < j ; pos ++ ) { int left = minCost ( a , i , pos , k , prefix , dp ) ; int right = minCost ( a , pos + 1 , j , k , prefix , dp ) ; best_cost = Math . Min ( best_cost , left + right + ( k * Combine ( prefix , i , j ) ) ) ; } return dp [ i , j ] = best_cost ; } public static int [ ] preprocess ( int [ ] a , int n ) { int [ ] p = new int [ n ] ; p [ 0 ] = a [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) p [ i ] = p [ i - 1 ] + a [ i ] ; return p ; } public static int Combine ( int [ ] p , int i , int j ) { if ( i == 0 ) return p [ j ] ; else return p [ j ] - p [ i - 1 ] ; } public static void Main ( String [ ] args ) { int n = 4 ; int [ ] a = { 4 , 5 , 6 , 7 } ; int k = 3 ; int [ , ] dp = new int [ n + 1 , n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) { for ( int j = 0 ; j < n + 1 ; j ++ ) { dp [ i , j ] = - 1 ; } } int [ ] prefix = preprocess ( a , n ) ; Console . WriteLine ( minCost ( a , 0 , n - 1 , k , prefix , dp ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j, pos
Iterator variables: i, j, pos
Class/struct names: GFG
C# program:
using System ; class GFG { static int minOperations ( int n ) { int [ ] dp = new int [ n + 1 ] ; int x ; dp [ 1 ] = 0 ; for ( int i = 2 ; i <= n ; i ++ ) { dp [ i ] = int . MaxValue ; if ( i % 2 == 0 ) { x = dp [ i / 2 ] ; if ( x + 1 < dp [ i ] ) { dp [ i ] = x + 1 ; } } if ( i % 3 == 0 ) { x = dp [ i / 3 ] ; if ( x + 1 < dp [ i ] ) { dp [ i ] = x + 1 ; } } x = dp [ i - 1 ] ; if ( x + 1 < dp [ i ] ) { dp [ i ] = x + 1 ; } } return dp [ n ] ; } public static void Main ( string [ ] args ) { int n = 15 ; Console . Write ( minOperations ( n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int ReverseBitonic ( int [ ] arr , int N ) { int i , j ; int [ ] lds = new int [ N ] ; for ( i = 0 ; i < N ; i ++ ) { lds [ i ] = 1 ; } for ( i = 1 ; i < N ; i ++ ) { for ( j = 0 ; j < i ; j ++ ) { if ( arr [ i ] < arr [ j ] && lds [ i ] < lds [ j ] + 1 ) { lds [ i ] = lds [ j ] + 1 ; } } } int [ ] lis = new int [ N ] ; for ( i = 0 ; i < N ; i ++ ) { lis [ i ] = 1 ; } for ( i = N - 2 ; i >= 0 ; i -- ) { for ( j = N - 1 ; j > i ; j -- ) { if ( arr [ i ] < arr [ j ] && lis [ i ] < lis [ j ] + 1 ) { lis [ i ] = lis [ j ] + 1 ; } } } int max = lis [ 0 ] + lds [ 0 ] - 1 ; for ( i = 1 ; i < N ; i ++ ) { if ( lis [ i ] + lds [ i ] - 1 > max ) { max = lis [ i ] + lds [ i ] - 1 ; } } return max ; } public static void Main ( ) { int [ ] arr = new int [ ] { 0 , 8 , 4 , 12 , 2 , 10 , 6 , 14 , 1 , 9 , 5 , 13 , 3 , 11 , 7 , 15 } ; int N = arr . Length ; Console . WriteLine ( " Length ▁ of ▁ LBS ▁ is ▁ " + ReverseBitonic ( arr , N ) ) ; } }

Index/key variables: N, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool findPath ( List < List < int > > maze , int xpos , int ypos , bool key ) { if ( xpos < 0 xpos >= maze . Count ypos < 0 ypos >= maze . Count ) return false ; if ( maze [ xpos ] [ ypos ] == '1' ) { if ( key == true ) if ( xpos == maze . Count - 1 && ypos == maze . Count - 1 ) return true ; return findPath ( maze , xpos + 1 , ypos , false ) || findPath ( maze , xpos , ypos + 1 , false ) ; } if ( xpos == maze . Count - 1 && ypos == maze . Count - 1 ) return true ; return findPath ( maze , xpos + 1 , ypos , key ) || findPath ( maze , xpos , ypos + 1 , key ) ; } static bool mazeProb ( List < List < int > > maze , int xpos , int ypos ) { bool key = true ; if ( findPath ( maze , xpos , ypos , key ) ) return true ; return false ; } public static void Main ( String [ ] args ) { int size = 3 ; List < List < int > > maze = new List < List < int > > ( size ) ; for ( int i = 0 ; i < size ; i ++ ) { maze . Add ( new List < int > ( ) ) ; } maze [ 0 ] . Add ( 0 ) ; maze [ 0 ] . Add ( 0 ) ; maze [ 0 ] . Add ( 1 ) ; maze [ 1 ] . Add ( 1 ) ; maze [ 1 ] . Add ( 0 ) ; maze [ 1 ] . Add ( 1 ) ; maze [ 2 ] . Add ( 1 ) ; maze [ 2 ] . Add ( 1 ) ; maze [ 2 ] . Add ( 0 ) ; if ( mazeProb ( maze , 0 , 0 ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Index/key variables: xpos, ypos
Accumulator variables: i
Iterator variables: i
Boolean variables: key
Class/struct names: GFG
C# program:
using System ; class GfG { static int FindMinimumCost ( int ind , int [ ] a , int n , int k , int [ ] dp ) { if ( ind == ( n - 1 ) ) return 0 ; else if ( dp [ ind ] != - 1 ) return dp [ ind ] ; else { int ans = int . MaxValue ; for ( int i = 1 ; i <= k ; i ++ ) { if ( ind + i < n ) ans = Math . Min ( ans , Math . Abs ( a [ ind + i ] - a [ ind ] ) + FindMinimumCost ( ind + i , a , n , k , dp ) ) ; else break ; } return dp [ ind ] = ans ; } } public static void Main ( ) { int [ ] a = { 10 , 30 , 40 , 50 , 20 } ; int k = 3 ; int n = a . Length ; int [ ] dp = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) dp [ i ] = - 1 ; Console . WriteLine ( FindMinimumCost ( 0 , a , n , k , dp ) ) ; } }

Index/key variables: i, ind, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GfG
C# program:
using System ; using System ; class GFG { public const int MAX = 100000 ; public static long [ ] prefix = new long [ MAX ] ; public static void sieve_modified ( ) { for ( int i = 2 ; i < MAX ; i += 2 ) { for ( int j = i ; j < MAX ; j += i ) { prefix [ j ] += i ; } } for ( int i = 1 ; i < MAX ; i ++ ) { prefix [ i ] += prefix [ i - 1 ] ; } } public static long sumEvenFactors ( int L , int R ) { return ( prefix [ R ] - prefix [ L - 1 ] ) ; } public static void Main ( string [ ] args ) { sieve_modified ( ) ; int l = 6 , r = 10 ; Console . Write ( sumEvenFactors ( l , r ) ) ; } }

Index/key variables: MAX, R, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int M = 20 ; static int [ , , , ] dp = new int [ M , 165 , M , 2 ] ; static int n , m ; static int count ( int pos , int sum , int rem , int tight , int nonz , List < int > num ) { if ( pos == num . Count ) { if ( rem == 0 && sum == n ) return 1 ; return 0 ; } if ( dp [ pos , sum , rem , tight ] != - 1 ) return dp [ pos , sum , rem , tight ] ; int ans = 0 ; int limit = ( tight != 0 ? 9 : num [ pos ] ) ; for ( int d = 0 ; d <= limit ; d ++ ) { if ( d == 0 && nonz != 0 ) continue ; int currSum = sum + d ; int currRem = ( rem * 10 + d ) % m ; int currF = ( tight != 0 || ( d < num [ pos ] ) ) ? 1 : 0 ; ans += count ( pos + 1 , currSum , currRem , currF , ( nonz != 0 d != 0 ) ? 1 : 0 , num ) ; } return dp [ pos , sum , rem , tight ] = ans ; } static int solve ( int x ) { List < int > num = new List < int > ( ) ; while ( x != 0 ) { num . Add ( x % 10 ) ; x /= 10 ; } num . Reverse ( ) ; for ( int i = 0 ; i < M ; i ++ ) for ( int j = 0 ; j < 165 ; j ++ ) for ( int k = 0 ; k < M ; k ++ ) for ( int l = 0 ; l < 2 ; l ++ ) dp [ i , j , k , l ] = - 1 ; return count ( 0 , 0 , 0 , 0 , 0 , num ) ; } public static void Main ( String [ ] args ) { int L = 1 , R = 100 ; n = 8 ; m = 2 ; Console . Write ( solve ( R ) - solve ( L ) ) ; } }

Index/key variables: pos
Accumulator variables: ans, d, i, j, k, l, x
Iterator variables: d, i, j, k, l
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int M = 20 ; static int [ , , ] dp = new int [ M , M , 2 ] ; static int K ; static List < int > num ; static int countInRangeUtil ( int pos , int cnt , int tight ) { if ( pos == num . Count ) { if ( cnt <= K ) return 1 ; return 0 ; } if ( dp [ pos , cnt , tight ] != - 1 ) return dp [ pos , cnt , tight ] ; int ans = 0 ; int limit = ( tight != 0 ? 9 : num [ pos ] ) ; for ( int dig = 0 ; dig <= limit ; dig ++ ) { int currCnt = cnt ; if ( dig != 0 ) currCnt ++ ; int currTight = tight ; if ( dig < num [ pos ] ) currTight = 1 ; ans += countInRangeUtil ( pos + 1 , currCnt , currTight ) ; } return dp [ pos , cnt , tight ] = ans ; } static int countInRange ( int x ) { num = new List < int > ( ) ; while ( x != 0 ) { num . Add ( x % 10 ) ; x /= 10 ; } num . Reverse ( ) ; for ( int i = 0 ; i < M ; i ++ ) for ( int j = 0 ; j < M ; j ++ ) for ( int k = 0 ; k < 2 ; k ++ ) dp [ i , j , k ] = - 1 ; return countInRangeUtil ( 0 , 0 , 0 ) ; } public static void Main ( ) { int L = 1 , R = 1000 ; K = 3 ; Console . WriteLine ( countInRange ( R ) - countInRange ( L - 1 ) ) ; L = 9995 ; R = 10005 ; K = 2 ; Console . WriteLine ( countInRange ( R ) - countInRange ( L - 1 ) ) ; } }

Index/key variables: pos
Accumulator variables: ans, currCnt, dig, i, j, k, x
Iterator variables: dig, i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int N = 1000 ; static int find ( int index , int openbrk , int n , int [ , ] dp , int [ ] adj ) { if ( openbrk < 0 ) { return 0 ; } if ( index == n ) { if ( openbrk == 0 ) { return 1 ; } else { return 0 ; } } if ( dp [ index , openbrk ] != - 1 ) { return dp [ index , openbrk ] ; } if ( adj [ index ] == 1 ) { dp [ index , openbrk ] = find ( index + 1 , openbrk + 1 , n , dp , adj ) ; } else { dp [ index , openbrk ] = find ( index + 1 , openbrk + 1 , n , dp , adj ) + find ( index + 1 , openbrk - 1 , n , dp , adj ) ; } return dp [ index , openbrk ] ; } public static void Main ( ) { int [ , ] dp = new int [ N , N ] ; int n = 2 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { dp [ i , j ] = - 1 ; } } int [ ] adj = { 1 , 0 , 0 , 0 } ; Console . WriteLine ( find ( 0 , 0 , 2 * n , dp , adj ) ) ; } }

Index/key variables: index
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findMaxValUtil ( int [ ] arr , int n , int num , int maxLimit , int ind , ref int ans ) { if ( ind == n ) { ans = Math . Max ( ans , num ) ; return ; } if ( num - arr [ ind ] >= 0 ) { findMaxValUtil ( arr , n , num - arr [ ind ] , maxLimit , ind + 1 , ref ans ) ; } if ( num + arr [ ind ] <= maxLimit ) { findMaxValUtil ( arr , n , num + arr [ ind ] , maxLimit , ind + 1 , ref ans ) ; } } static int findMaxVal ( int [ ] arr , int n , int num , int maxLimit ) { int ans = 0 ; int ind = 0 ; findMaxValUtil ( arr , n , num , maxLimit , ind , ref ans ) ; return ans ; } public static void Main ( ) { int num = 1 ; int [ ] arr = { 3 , 10 , 6 , 4 , 5 } ; int n = arr . Length ; int maxLimit = 15 ; Console . Write ( findMaxVal ( arr , n , num , maxLimit ) ) ; } }

Index/key variables: ind
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; using System . Linq ; using System . Collections ; class GFG { static void printSets ( List < int > set1 , List < int > set2 ) { int i ; for ( i = 0 ; i < set1 . Count ; i ++ ) { Console . Write ( set1 [ i ] + " ▁ " ) ; } Console . WriteLine ( ) ; for ( i = 0 ; i < set2 . Count ; i ++ ) { Console . Write ( set2 [ i ] + " ▁ " ) ; } } static bool findSets ( int [ ] arr , int n , ref List < int > set1 , ref List < int > set2 , int sum1 , int sum2 , int pos ) { if ( pos == n ) { if ( sum1 == sum2 ) { printSets ( set1 , set2 ) ; return true ; } else return false ; } set1 . Add ( arr [ pos ] ) ; bool res = findSets ( arr , n , ref set1 , ref set2 , sum1 + arr [ pos ] , sum2 , pos + 1 ) ; if ( res == true ) return res ; set1 . RemoveAt ( set1 . Count - 1 ) ; set2 . Add ( arr [ pos ] ) ; res = findSets ( arr , n , ref set1 , ref set2 , sum1 , sum2 + arr [ pos ] , pos + 1 ) ; if ( res == false ) if ( set2 . Count > 0 ) set2 . RemoveAt ( set2 . Count - 1 ) ; return res ; } static bool isPartitionPoss ( int [ ] arr , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; if ( sum % 2 != 0 ) return false ; List < int > set1 = new List < int > ( ) ; List < int > set2 = new List < int > ( ) ; return findSets ( arr , n , ref set1 , ref set2 , 0 , 0 , 0 ) ; } public static void Main ( ) { int [ ] arr = { 5 , 5 , 1 , 11 } ; int n = arr . Length ; if ( isPartitionPoss ( arr , n ) == false ) { Console . Write ( " - 1" ) ; } } }

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