dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int [ , ] C = new int [ 1000 , 1000 ] ; static void binomialCoeff ( int n ) { int i , j ; for ( i = 0 ; i <= n ; i ++ ) { for ( j = 0 ; j <= i ; j ++ ) { if ( j == 0 j == i ) C [ i , j ] = 1 ; else C [ i , j ] = C [ i - 1 , j - 1 ] + C [ i - 1 , j ] ; } } } static int numberOfWays ( int x , int y , int z ) { binomialCoeff ( Math . Max ( x , Math . Max ( y , z ) ) ) ; int sum = 0 ; for ( int i = 1 ; i <= z ; i ++ ) { sum = ( sum + C [ z , i ] ) ; } int sum1 = 0 ; for ( int i = 1 ; i <= y ; i ++ ) { for ( int j = i + 1 ; j <= x ; j ++ ) { sum1 = ( sum1 + ( C [ y , i ] * C [ x , j ] ) ) ; } } sum1 = ( sum * sum1 ) ; return sum1 ; } public static void Main ( String [ ] args ) { int x = 3 ; int y = 2 ; int z = 1 ; Console . WriteLine ( numberOfWays ( x , y , z ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static int findCost ( string str , int [ ] arr , int n ) { long costofC = 0 , costofO = 0 , costofD = 0 , costofE = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ' c ' ) { costofC += arr [ i ] ; } else if ( str [ i ] == ' o ' ) { costofO = Math . Min ( costofC , costofO + arr [ i ] ) ; } else if ( str [ i ] == ' d ' ) { costofD = Math . Min ( costofO , costofD + arr [ i ] ) ; } else if ( str [ i ] == ' e ' ) { costofE = Math . Min ( costofD , costofE + arr [ i ] ) ; } } return ( int ) costofE ; } public static void Main ( string [ ] args ) { string str = " geekcodergeeks " ; int [ ] arr = new int [ ] { 1 , 2 , 1 , 3 , 4 , 2 , 6 , 4 , 6 , 2 , 3 , 3 , 3 , 2 } ; int n = arr . Length ; Console . Write ( findCost ( str , arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: costofC, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findSubsequence ( int [ ] arr , int n ) { int len = 1 ; int tmp ; int i , j , d ; int [ , ] dp = new int [ n , 10 ] ; int [ ] cnt = new int [ 10 ] ; int locMax ; tmp = arr [ 0 ] ; while ( tmp > 0 ) { dp [ 0 , tmp % 10 ] = 1 ; tmp /= 10 ; } for ( i = 1 ; i < n ; i ++ ) { tmp = arr [ i ] ; locMax = 1 ; for ( int x = 0 ; x < 10 ; x ++ ) cnt [ x ] = 0 ; while ( tmp > 0 ) { cnt [ tmp % 10 ] = 1 ; tmp /= 10 ; } for ( d = 0 ; d <= 9 ; d ++ ) { if ( cnt [ d ] > 0 ) { dp [ i , d ] = 1 ; for ( j = 0 ; j < i ; j ++ ) { dp [ i , d ] = Math . Max ( dp [ i , d ] , dp [ j , d ] + 1 ) ; locMax = Math . Max ( dp [ i , d ] , locMax ) ; } } } for ( d = 0 ; d <= 9 ; d ++ ) { if ( cnt [ d ] > 0 ) { dp [ i , d ] = locMax ; } } len = Math . Max ( len , locMax ) ; } return len ; } public static void Main ( ) { int [ ] arr = { 1 , 12 , 44 , 29 , 33 , 96 , 89 } ; int n = arr . Length ; Console . WriteLine ( findSubsequence ( arr , n ) ) ; } }

Index/key variables: d, i, x
Accumulator variables: d, i, j, tmp, x
Iterator variables: d, i, j, x
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int M = 18 ; static int a , b ; static int [ , , , ] dp = new int [ M , 90 , 90 , 2 ] ; static int [ ] prime = { 2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 , 43 , 47 , 53 , 59 , 61 , 67 , 71 , 73 , 79 , 83 , 89 , 97 } ; static int count ( int pos , int even , int odd , int tight , List < int > num ) { if ( pos == num . Count ) { if ( ( num . Count & 1 ) != 0 ) { int t = odd ; odd = even ; even = t ; } int d = even - odd ; for ( int i = 0 ; i < 24 ; i ++ ) if ( d == prime [ i ] ) return 1 ; return 0 ; } if ( dp [ pos , even , odd , tight ] != - 1 ) return dp [ pos , even , odd , tight ] ; int ans = 0 ; int limit = ( tight != 0 ? 9 : num [ pos ] ) ; for ( int d = 0 ; d <= limit ; d ++ ) { int currF = tight , currEven = even ; int currOdd = odd ; if ( d < num [ pos ] ) currF = 1 ; if ( ( pos & 1 ) != 0 ) currOdd += d ; else currEven += d ; ans += count ( pos + 1 , currEven , currOdd , currF , num ) ; } return dp [ pos , even , odd , 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 < dp . GetLength ( 0 ) ; i ++ ) for ( int j = 0 ; j < dp . GetLength ( 1 ) ; j ++ ) for ( int k = 0 ; k < dp . GetLength ( 2 ) ; k ++ ) for ( int k1 = 0 ; k1 < dp . GetLength ( 3 ) ; k1 ++ ) dp [ i , j , k , k1 ] = - 1 ; return count ( 0 , 0 , 0 , 0 , num ) ; } public static void Main ( String [ ] args ) { int L = 1 , R = 50 ; Console . WriteLine ( solve ( R ) - solve ( L - 1 ) ) ; L = 50 ; R = 100 ; Console . WriteLine ( solve ( R ) - solve ( L - 1 ) ) ; } }

Index/key variables: i, pos
Accumulator variables: ans, currEven, currOdd, d, i, j, k, k1, x
Iterator variables: d, i, j, k, k1
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static readonly int N = 5005 ; static int n , k ; static List < int > [ ] gr = new List < int > [ N ] ; static int [ , ] d = new int [ N , 505 ] ; static int ans = 0 ; static void Add_edge ( int x , int y ) { gr [ x ] . Add ( y ) ; gr [ y ] . Add ( x ) ; } static void dfs ( int v , int par ) { d [ v , 0 ] = 1 ; foreach ( int i in gr [ v ] ) { if ( i != par ) { dfs ( i , v ) ; for ( int j = 1 ; j <= k ; j ++ ) ans += d [ i , j - 1 ] * d [ v , k - j ] ; for ( int j = 1 ; j <= k ; j ++ ) d [ v , j ] += d [ i , j - 1 ] ; } } } public static void Main ( String [ ] args ) { n = 5 ; k = 2 ; for ( int i = 0 ; i < N ; i ++ ) gr [ i ] = new List < int > ( ) ; Add_edge ( 1 , 2 ) ; Add_edge ( 2 , 3 ) ; Add_edge ( 3 , 4 ) ; Add_edge ( 2 , 5 ) ; dfs ( 1 , 0 ) ; Console . Write ( ans ) ; } }

Index/key variables: N, i, v, x, y
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int findXorSum ( int [ ] arr , int n ) { int sum = 0 ; int mul = 1 ; for ( int i = 0 ; i < 30 ; i ++ ) { int c_odd = 0 ; bool odd = false ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( arr [ j ] & ( 1 << i ) ) > 0 ) odd = ( ! odd ) ; if ( odd ) c_odd ++ ; } for ( int j = 0 ; j < n ; j ++ ) { sum += ( mul * c_odd ) ; if ( ( arr [ j ] & ( 1 << i ) ) > 0 ) c_odd = ( n - j - c_odd ) ; } mul *= 2 ; } return sum ; } static void Main ( ) { int [ ] arr = { 3 , 8 , 13 } ; int n = arr . Length ; Console . WriteLine ( findXorSum ( arr , n ) ) ; } }

Index/key variables: j
Accumulator variables: c_odd, i, j, mul, sum
Iterator variables: i, j
Boolean variables: odd
Class/struct names: GFG
C# program:
using System ; class GFG { static int charVal ( string s , int i ) { if ( s [ i ] == '0' ) { return 0 ; } else if ( s [ i ] == '1' ) { return 1 ; } else { return 2 ; } } static int countMinimalReplacements ( string s , int i , int prev , int [ , ] dp , int n ) { if ( i == n ) { return 0 ; } if ( dp [ i , prev ] != - 1 ) { return dp [ i , prev ] ; } int val = charVal ( s , i ) ; int ans = int . MaxValue ; if ( val == prev ) { val = 0 ; for ( int cur = 0 ; cur <= 2 ; cur ++ ) { if ( cur == prev ) { continue ; } val = 1 + countMinimalReplacements ( s , i + 1 , cur , dp , n ) ; ans = Math . Min ( ans , val ) ; } } { ans = countMinimalReplacements ( s , i + 1 , val , dp , n ) ; } return dp [ i , val ] = ans ; } public static void Main ( ) { string s = "201220211" ; int n = s . Length ; int [ , ] dp = new int [ n , 3 ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { dp [ i , j ] = - 1 ; } } int val = charVal ( s , 0 ) ; Console . WriteLine ( countMinimalReplacements ( s , 1 , val , dp , n ) ) ; } }

Index/key variables: i
Accumulator variables: cur, i, j
Iterator variables: cur, i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 50 ; static Boolean hasPath ( int [ , ] maze , int [ , ] sol , int N ) { int i , j , k ; for ( i = 0 ; i < N ; i ++ ) for ( j = 0 ; j < N ; j ++ ) sol [ i , j ] = 0 ; Boolean [ , ] CRF = new Boolean [ N , N ] ; CRF [ N - 1 , N - 1 ] = true ; for ( k = N - 1 ; k >= 0 ; k -- ) { for ( j = k ; j >= 0 ; j -- ) { if ( ! ( k == N - 1 && j == N - 1 ) ) { for ( int a = 0 ; a <= maze [ k , j ] ; a ++ ) { if ( ( j + a < N && CRF [ k , j + a ] == true ) || ( k + a < N && CRF [ k + a , j ] == true ) ) { CRF [ k , j ] = true ; break ; } } for ( int a = 0 ; a <= maze [ j , k ] ; a ++ ) { if ( ( k + a < N && CRF [ j , k + a ] == true ) || ( j + a < N && CRF [ j + a , k ] == true ) ) { CRF [ j , k ] = true ; break ; } } } } } if ( CRF [ 0 , 0 ] == false ) return false ; i = 0 ; j = 0 ; while ( ! ( i == N - 1 && j == N - 1 ) ) { sol [ i , j ] = 1 ; if ( maze [ i , j ] > 0 ) for ( int a = 1 ; a <= maze [ i , j ] ; a ++ ) { if ( ( j + a < N && CRF [ i , j + a ] == true ) ) { j = j + a ; break ; } else if ( ( i + a < N && CRF [ i + a , j ] == true ) ) { i = i + a ; break ; } } } sol [ N - 1 , N - 1 ] = 1 ; return true ; } static void printMatrix ( int [ , ] sol , int N ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) Console . Write ( sol [ i , j ] + " ▁ " ) ; Console . WriteLine ( ) ; } } public static void Main ( String [ ] args ) { int [ , ] maze = { { 2 , 2 , 1 , 1 , 0 } , { 0 , 0 , 3 , 0 , 0 } , { 1 , 0 , 0 , 0 , 0 } , { 0 , 0 , 2 , 0 , 1 } , { 0 , 0 , 3 , 0 , 0 } } ; int N = maze . GetLength ( 0 ) ; int [ , ] sol = new int [ N , MAX ] ; if ( hasPath ( maze , sol , N ) ) printMatrix ( sol , N ) ; else Console . WriteLine ( " No ▁ path ▁ exists " ) ; } }

Accumulator variables: a, i, j, k
Iterator variables: a, i, j, k
Class/struct names: GFG
C# program:
using System ; class GfG { static bool checkCombinations ( int [ ] a , int n ) { int pow_set_size = ( int ) Math . Pow ( 2 , n ) ; int counter , j ; for ( counter = 0 ; counter < pow_set_size ; counter ++ ) { int sum = 0 ; for ( j = 0 ; j < n ; j ++ ) { if ( ( counter & ( 1 << j ) ) != 0 ) else } if ( sum % ( 24 * 60 ) == 0 ) return true ; } return false ; } public static void Main ( ) { int [ ] a = { 60 , 60 , 120 } ; int n = a . Length ; if ( checkCombinations ( a , n ) ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } }

Accumulator variables: counter, j
Iterator variables: counter, j
Class/struct names: GfG
C# program:
using System ; class GFG { static int n = 4 ; static int m = 4 ; static float calcProbability ( int [ , ] M , int k ) { float [ , ] dp = new float [ m , n ] ; float [ ] sum = new float [ n ] ; for ( int j = 0 ; j < n ; j ++ ) { dp [ 0 , j ] = M [ 0 , j ] ; sum [ 0 ] = sum [ 0 ] + dp [ 0 , j ] ; } for ( int i = 1 ; i < m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { dp [ i , j ] += dp [ i - 1 , j ] / sum [ i - 1 ] + M [ i , j ] ; sum [ i ] += dp [ i , j ] ; } } return dp [ n - 1 , k - 1 ] / sum [ n - 1 ] ; } public static void Main ( ) { int [ , ] M = { { 1 , 1 , 0 , 3 } , { 2 , 3 , 2 , 3 } , { 9 , 3 , 0 , 2 } , { 2 , 3 , 2 , 2 } } ; int k = 3 ; Console . Write ( calcProbability ( M , k ) ) ; } }

Index/key variables: i, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int MaximumNumbers ( String s ) { int n = s . Length ; int [ ] remIndex = { - 1 , - 1 , - 1 } ; remIndex [ 0 ] = 0 ; int [ ] res = new int [ n + 1 ] ; int r = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { r = ( r + s [ i - 1 ] - '0' ) % 3 ; res [ i ] = res [ i - 1 ] ; if ( remIndex [ r ] != - 1 ) res [ i ] = Math . Max ( res [ i ] , res [ remIndex [ r ] ] + 1 ) ; remIndex [ r ] = i + 1 ; } return res [ n ] ; } public static void Main ( String [ ] args ) { String s = "12345" ; Console . WriteLine ( MaximumNumbers ( s ) ) ; } }

Index/key variables: i, n, r
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int INF = 99999 ; static int findMinimumSteps ( int [ , ] mat , int x , int y , int n ) { int i , j , k ; int [ , ] dist = new int [ n , n ] ; for ( i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < n ; j ++ ) { if ( mat [ i , j ] == 0 ) dist [ i , j ] = INF ; else dist [ i , j ] = 1 ; if ( i == j ) dist [ i , j ] = 1 ; } } for ( k = 0 ; k < n ; k ++ ) { for ( i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < n ; j ++ ) { if ( dist [ i , k ] + dist [ k , j ] < dist [ i , j ] ) dist [ i , j ] = dist [ i , k ] + dist [ k , j ] ; } } } if ( dist [ x , y ] < INF ) return dist [ x , y ] ; else return - 1 ; } public static void Main ( ) { int [ , ] mat = { { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 } , { 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 , 0 , 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 , 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 , 1 } } ; int x = 2 , y = 3 ; int size = mat . GetLength ( 0 ) ; Console . WriteLine ( findMinimumSteps ( mat , x , y , size ) ) ; } }

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

Accumulator variables: i, j, res
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX_K = 15 ; static int [ ] fac = new int [ MAX_K ] ; static void factorial ( int k ) { fac [ 0 ] = 1 ; for ( int i = 1 ; i <= k + 1 ; i ++ ) { fac [ i ] = ( i * fac [ i - 1 ] ) ; } } static int bin ( int a , int b ) { int ans = ( ( fac [ a ] ) / ( fac [ a - b ] * fac [ b ] ) ) ; return ans ; } static int sumofn ( int n , int k ) { int p = 0 ; int num1 , temp ; int [ ] arr = new int [ 1000 ] ; for ( int j = 1 ; j <= k ; j ++ ) { if ( j == 1 ) { num1 = ( n * ( n + 1 ) ) / 2 ; arr [ p ++ ] = num1 ; temp = num1 ; } else { temp = ( ( int ) Math . 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 ; } public static void Main ( ) { int n = 5 , k = 2 ; factorial ( k ) ; Console . WriteLine ( sumofn ( n , k ) ) ; } }

Index/key variables: MAX_K, a, b, i
Accumulator variables: i, j, p, s
Iterator variables: i, j, s
Class/struct names: GFG
C# program:
using System ; class solution { static int max = 4 ; static int countWays ( int index , int cnt , int [ , ] dp , int n , int m , int k ) { if ( index == n ) { if ( cnt == k ) return 1 ; else return 0 ; } if ( dp [ index , cnt ] != - 1 ) return dp [ index , cnt ] ; int ans = 0 ; ans += countWays ( index + 1 , cnt , dp , n , m , k ) ; ans += ( m - 1 ) * countWays ( index + 1 , cnt + 1 , dp , n , m , k ) ; return dp [ index , cnt ] = ans ; } public static void Main ( ) { int n = 3 , m = 3 , k = 2 ; int [ , ] dp = new int [ n + 1 , max ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) for ( int j = 0 ; j < max ; j ++ ) dp [ i , j ] = - 1 ; Console . WriteLine ( m * countWays ( 1 , 0 , dp , n , m , k ) ) ; } }

Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: solution
C# program:
using System ; class GFG { static int MAX = 300 ; static int checkFunc ( int i , int j , string st ) { if ( st [ i ] == ' ( ' && st [ j ] == ' ) ' ) return 1 ; if ( st [ i ] == ' ( ' && st [ j ] == ' ? ' ) return 1 ; if ( st [ i ] == ' ? ' && st [ j ] == ' ) ' ) return 1 ; if ( st [ i ] == ' [ ' && st [ j ] == ' ] ' ) return 1 ; if ( st [ i ] == ' [ ' && st [ j ] == ' ? ' ) return 1 ; if ( st [ i ] == ' ? ' && st [ j ] == ' ] ' ) return 1 ; if ( st [ i ] == ' { ' && st [ j ] == ' } ' ) return 1 ; if ( st [ i ] == ' { ' && st [ j ] == ' ? ' ) return 1 ; if ( st [ i ] == ' ? ' && st [ j ] == ' } ' ) return 1 ; return 0 ; } static int countRec ( int start , int end , int [ , ] dp , string st ) { int sum = 0 ; if ( start > end ) return 1 ; if ( dp [ start , end ] != - 1 ) return dp [ start , end ] ; int i ; for ( i = start + 1 ; i <= end ; i += 2 ) { if ( checkFunc ( start , i , st ) == 1 ) { sum = sum + countRec ( start + 1 , i - 1 , dp , st ) * countRec ( i + 1 , end , dp , st ) ; } else if ( st [ start ] == ' ? ' && st [ i ] == ' ? ' ) { sum = sum + countRec ( start + 1 , i - 1 , dp , st ) * countRec ( i + 1 , end , dp , st ) * 3 ; } } return dp [ start , end ] = sum ; } static int countWays ( string st ) { int n = st . Length ; if ( n % 2 == 1 ) return 0 ; int [ , ] dp = new int [ MAX , MAX ] ; for ( int i = 0 ; i < MAX ; i ++ ) for ( int j = 0 ; j < MAX ; j ++ ) dp [ i , j ] = - 1 ; return countRec ( 0 , n - 1 , dp , st ) ; } public static void Main ( ) { string st = " ( ? ( [ ? ) ] ? } ? " ; Console . WriteLine ( countWays ( st ) ) ; } }

Index/key variables: i, j, start
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ , , , ] dp = new int [ 64 , 64 , 64 , 2 ] ; static int func ( int third , int seta , int setb , int carry , int number ) { if ( third > - 1 && seta > - 1 && setb > - 1 && carry > - 1 ) if ( dp [ third , seta , setb , carry ] != - 1 ) return dp [ third , seta , setb , carry ] ; int shift = ( number >> third ) ; if ( shift == 0 && seta == 0 && setb == 0 && carry == 0 ) return 1 ; if ( shift == 0 seta < 0 setb < 0 ) return 0 ; int mask = shift & 1 ; dp [ third , seta , setb , carry ] = 0 ; if ( ( mask == 1 ) && carry == 1 ) { dp [ third , seta , setb , carry ] += func ( third + 1 , seta , setb , 0 , number ) + func ( third + 1 , seta - 1 , setb - 1 , 1 , number ) ; } else if ( mask == 1 && carry == 0 ) { dp [ third , seta , setb , carry ] += func ( third + 1 , seta - 1 , setb , 0 , number ) + func ( third + 1 , seta , setb - 1 , 0 , number ) ; } else if ( mask == 0 && carry == 1 ) { dp [ third , seta , setb , carry ] += func ( third + 1 , seta - 1 , setb , 1 , number ) + func ( third + 1 , seta , setb - 1 , 1 , number ) ; } else if ( mask == 0 && carry == 0 ) { dp [ third , seta , setb , carry ] += func ( third + 1 , seta , setb , 0 , number ) + func ( third + 1 , seta - 1 , setb - 1 , 1 , number ) ; } return dp [ third , seta , setb , carry ] ; } static int possibleSwaps ( int a , int b , int c ) { for ( int q = 0 ; q < 64 ; q ++ ) { for ( int r = 0 ; r < 64 ; r ++ ) { for ( int p = 0 ; p < 64 ; p ++ ) { for ( int d = 0 ; d < 2 ; d ++ ) { dp [ q , r , p , d ] = - 1 ; } } } } int ans = func ( 0 , a , b , 0 , c ) ; return ans ; } public static void Main ( String [ ] args ) { int x = 2 , y = 2 , c = 20 ; Console . WriteLine ( possibleSwaps ( x , y , c ) ) ; } }

Accumulator variables: d, p, q, r
Iterator variables: d, p, q, r
Class/struct names: GFG
C# program:
using System ; class GFG { static int calculateEvenSum ( int n ) { if ( n <= 0 ) return 0 ; int [ ] fibo = new int [ 2 * n + 1 ] ; fibo [ 0 ] = 0 ; fibo [ 1 ] = 1 ; int sum = 0 ; for ( int i = 2 ; i <= 2 * n ; i ++ ) { fibo [ i ] = fibo [ i - 1 ] + fibo [ i - 2 ] ; if ( i % 2 == 0 ) sum += fibo [ i ] ; } return sum ; } static public void Main ( ) { int n = 8 ; Console . WriteLine ( " Even ▁ indexed ▁ Fibonacci ▁ Sum ▁ upto ▁ " + n + " ▁ terms : ▁ " + calculateEvenSum ( n ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 1000 ; static int [ ] f = new int [ MAX ] ; static int fib ( int n ) { if ( n == 0 ) { return 0 ; } if ( n == 1 n == 2 ) { return ( f [ n ] = 1 ) ; } if ( f [ n ] == 1 ) { return f [ n ] ; } int k = ( n % 2 == 1 ) ? ( n + 1 ) / 2 : n / 2 ; f [ n ] = ( n % 2 == 1 ) ? ( fib ( k ) * fib ( k ) + fib ( k - 1 ) * fib ( k - 1 ) ) : ( 2 * fib ( k - 1 ) + fib ( k ) ) * fib ( k ) ; return f [ n ] ; } static int calculateEvenSum ( int n ) { return ( fib ( 2 * n + 1 ) - 1 ) ; } public static void Main ( ) { int n = 8 ; Console . WriteLine ( " Even ▁ indexed ▁ Fibonacci ▁ Sum ▁ upto ▁ " + n + " ▁ terms : ▁ " + calculateEvenSum ( n ) ) ; } }

Index/key variables: MAX, n
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 32768 ; static int [ ] arr = new int [ 2 * MAX ] ; static void gouldSequence ( ) { arr [ 0 ] = 1 ; int i = 1 ; int p = 1 ; while ( i <= MAX ) { int j = 0 ; while ( j < i ) { arr [ i + j ] = 2 * arr [ j ] ; j ++ ; } i = ( 1 << p ) ; p ++ ; } } static void printSequence ( int n ) { for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } public static void Main ( ) { gouldSequence ( ) ; int n = 16 ; printSequence ( n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, p
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int factorial ( int n ) { int res = 1 , i ; for ( i = 2 ; i <= n ; i ++ ) res *= i ; return res ; } static int countWays ( int m , int n ) { m = m - 1 ; n = n - 1 ; return factorial ( m + n ) / ( factorial ( m ) * factorial ( n ) ) ; } static void Main ( ) { int m = 5 ; int n = 5 ; int result = countWays ( m , n ) ; Console . WriteLine ( result ) ; } }

Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MatrixChainOrder ( int [ ] p , int n ) { int [ , ] dp = new int [ n , n ] ; for ( int i = 1 ; i < n ; i ++ ) dp [ i , i ] = 0 ; for ( int L = 1 ; L < n - 1 ; L ++ ) for ( int i = 1 ; i < n - L ; i ++ ) dp [ i , i + L ] = Math . 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 ] ) ; return dp [ 1 , n - 1 ] ; } public static void Main ( ) { int [ ] arr = { 10 , 20 , 30 , 40 , 30 } ; int size = arr . Length ; Console . WriteLine ( " Minimum ▁ number ▁ of ▁ multiplications ▁ is ▁ " + MatrixChainOrder ( arr , size ) ) ; } }

Index/key variables: i
Accumulator variables: L, i
Iterator variables: L, i
Class/struct names: GFG
C# program:
using System ; class GFG { static int CommomSubsequencesCount ( string s , string t ) { int n1 = s . Length ; int n2 = t . Length ; int [ , ] dp = new int [ n1 + 1 , n2 + 1 ] ; for ( int i = 0 ; i <= n1 ; i ++ ) { for ( int j = 0 ; j <= n2 ; j ++ ) { dp [ i , j ] = 0 ; } } for ( int i = 1 ; i <= n1 ; i ++ ) { for ( int j = 1 ; j <= n2 ; j ++ ) { if ( s [ i - 1 ] == t [ j - 1 ] ) dp [ i , j ] = 1 + dp [ i , j - 1 ] + dp [ i - 1 , j ] ; else dp [ i , j ] = dp [ i , j - 1 ] + dp [ i - 1 , j ] - dp [ i - 1 , j - 1 ] ; } } return dp [ n1 , n2 ] ; } public static void Main ( ) { string s = " ajblqcpdz " ; string t = " aefcnbtdi " ; Console . Write ( CommomSubsequencesCount ( s , t ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG