dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int MAX = 100 ; public static bool allones ( string s , int n ) { int co = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) co += ( s [ i ] == '1' ? 1 : 0 ) ; return ( co == n ) ; } public static int findlength ( int [ ] arr , string s , int n , int ind , int st , int [ , ] dp ) { if ( ind >= n ) return 0 ; if ( dp [ ind , st ] != - 1 ) return dp [ ind , st ] ; if ( st == 0 ) return dp [ ind , st ] = Math . Max ( arr [ ind ] + findlength ( arr , s , n , ind + 1 , 1 , dp ) , findlength ( arr , s , n , ind + 1 , 0 , dp ) ) ; else return dp [ ind , st ] = Math . Max ( arr [ ind ] + findlength ( arr , s , n , ind + 1 , 1 , dp ) , 0 ) ; } public static int maxLen ( string s , int n ) { if ( allones ( s , n ) ) return - 1 ; int [ ] arr = new int [ MAX ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = ( s [ i ] == '0' ? 1 : - 1 ) ; int [ , ] dp = new int [ MAX , 3 ] ; for ( int i = 0 ; i < MAX ; i ++ ) for ( int j = 0 ; j < 3 ; j ++ ) dp [ i , j ] = - 1 ; return findlength ( arr , s , n , 0 , 0 , dp ) ; } static void Main ( ) { string s = "11000010001" ; int n = 11 ; Console . Write ( maxLen ( s , n ) ) ; } }

Index/key variables: MAX, i, ind
Accumulator variables: co, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isSafe ( int x , int y ) { return ( x < 4 && y < 3 ) ; } static int minJump ( int [ , ] height , int x , int y ) { if ( x == 4 - 1 && y == 3 - 1 ) return 0 ; int diag = int . MaxValue ; if ( isSafe ( x + 1 , y + 1 ) ) diag = minJump ( height , x + 1 , y + 1 ) + Math . Abs ( height [ x , y ] - height [ x + 1 , y + 1 ] ) ; int down = int . MaxValue ; if ( isSafe ( x + 1 , y ) ) down = minJump ( height , x + 1 , y ) + Math . Abs ( height [ x , y ] - height [ x + 1 , y ] ) ; int right = int . MaxValue ; if ( isSafe ( x , y + 1 ) ) right = minJump ( height , x , y + 1 ) + Math . Abs ( height [ x , y ] - height [ x , y + 1 ] ) ; return Math . Min ( down , Math . Min ( right , diag ) ) ; } public static void Main ( ) { int [ , ] height = { { 5 , 4 , 2 } , { 9 , 2 , 1 } , { 2 , 5 , 9 } , { 1 , 3 , 11 } } ; Console . Write ( minJump ( height , 0 , 0 ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSum ( int [ ] arr , int N , int k ) { int [ ] MS = new int [ N ] ; MS [ N - 1 ] = arr [ N - 1 ] ; for ( int i = N - 2 ; i >= 0 ; i -- ) { if ( i + k + 1 >= N ) MS [ i ] = Math . Max ( arr [ i ] , MS [ i + 1 ] ) ; else MS [ i ] = Math . Max ( arr [ i ] + MS [ i + k + 1 ] , MS [ i + 1 ] ) ; } return MS [ 0 ] ; } public static void Main ( ) { int N = 10 , k = 2 ; int [ ] arr = { 50 , 70 , 40 , 50 , 90 , 70 , 60 , 40 , 70 , 50 } ; Console . WriteLine ( maxSum ( arr , N , k ) ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxLength ( String s , int n ) { int invalidOpenBraces = 0 ; int invalidCloseBraces = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ' ( ' ) { invalidOpenBraces ++ ; } else { if ( invalidOpenBraces == 0 ) { invalidCloseBraces ++ ; } else { invalidOpenBraces -- ; } } } return ( n - ( invalidOpenBraces + invalidCloseBraces ) ) ; } public static void Main ( ) { string s = " ( ) ( ( ( ( ( ( ) " ; int n = s . Length ; Console . WriteLine ( maxLength ( s , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, invalidCloseBraces, invalidOpenBraces
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void alternateSubarray ( bool [ ] arr , int n ) { int [ ] len = new int [ n ] ; len [ n - 1 ] = 1 ; for ( int i = n - 2 ; i >= 0 ; -- i ) { if ( arr [ i ] ^ arr [ i + 1 ] == true ) len [ i ] = len [ i + 1 ] + 1 ; else len [ i ] = 1 ; } for ( int i = 0 ; i < n ; ++ i ) Console . Write ( len [ i ] + " ▁ " ) ; } public static void Main ( ) { bool [ ] arr = { true , false , true , false , false , true } ; int n = arr . Length ; alternateSubarray ( arr , n ) ; } }

Index/key variables: i, n
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class Test { static void alternateSubarray ( bool [ ] arr , int n ) { int count = 1 ; bool prev = arr [ 0 ] ; for ( int i = 1 ; i < n ; ++ i ) { if ( ( arr [ i ] ^ prev ) == false ) { while ( count > 0 ) { Console . Write ( count -- + " ▁ " ) ; } } ++ count ; prev = arr [ i ] ; } while ( count != 0 ) { Console . Write ( count -- + " ▁ " ) ; } } public static void Main ( ) { bool [ ] arr = { true , false , true , false , false , true } ; int n = arr . Length ; alternateSubarray ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Class/struct names: Test
C# program:
using System ; class GFG { static int MAX = 10 ; static int lcs ( int [ , , ] dp , int [ ] arr1 , int n , int [ ] arr2 , int m , int k ) { if ( k < 0 ) return - 10000000 ; if ( n < 0 m < 0 ) return 0 ; int ans = dp [ n , m , k ] ; if ( ans != - 1 ) return ans ; try { ans = Math . Max ( lcs ( dp , arr1 , n - 1 , arr2 , m , k ) , lcs ( dp , arr1 , n , arr2 , m - 1 , k ) ) ; if ( arr1 [ n - 1 ] == arr2 [ m - 1 ] ) ans = Math . Max ( ans , 1 + lcs ( dp , arr1 , n - 1 , arr2 , m - 1 , k ) ) ; ans = Math . Max ( ans , 1 + lcs ( dp , arr1 , n - 1 , arr2 , m - 1 , k - 1 ) ) ; } catch ( Exception e ) { } return ans ; } public static void Main ( String [ ] args ) { int k = 1 ; int [ ] arr1 = { 1 , 2 , 3 , 4 , 5 } ; int [ ] arr2 = { 5 , 3 , 1 , 4 , 2 } ; int n = arr1 . Length ; int m = arr2 . Length ; int [ , , ] dp = new int [ MAX , MAX , MAX ] ; for ( int i = 0 ; i < MAX ; i ++ ) for ( int j = 0 ; j < MAX ; j ++ ) for ( int l = 0 ; l < MAX ; l ++ ) dp [ i , j , l ] = - 1 ; Console . WriteLine ( lcs ( dp , arr1 , n , arr2 , m , k ) ) ; } }

Accumulator variables: i, j, l
Iterator variables: i, j, l
Class/struct names: GFG
C# program:
using System ; public class GFG { static long countWays ( int n ) { long [ , ] dp = new long [ 2 , n + 1 ] ; dp [ 0 , 1 ] = 1 ; dp [ 1 , 1 ] = 2 ; for ( int i = 2 ; i <= n ; i ++ ) { dp [ 0 , i ] = dp [ 0 , i - 1 ] + dp [ 1 , i - 1 ] ; dp [ 1 , i ] = dp [ 0 , i - 1 ] * 2 + dp [ 1 , i - 1 ] ; } return dp [ 0 , n ] + dp [ 1 , n ] ; } public static void Main ( ) { int n = 5 ; Console . Write ( " Total ▁ no ▁ of ▁ ways ▁ with ▁ n ▁ = ▁ " + n + " ▁ are : ▁ " + countWays ( n ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countways ( int n ) { int [ ] A = new int [ n + 1 ] ; A [ 0 ] = 1 ; A [ 1 ] = 3 ; A [ 2 ] = 7 ; for ( int i = 2 ; i <= n ; i ++ ) { A [ i ] = 2 * A [ i - 1 ] + A [ i - 2 ] ; } return A [ n ] ; } public static void Main ( ) { int n = 5 ; Console . Write ( countways ( n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int maxLenSub ( int [ ] arr , int n ) { int [ ] mls = new int [ n ] ; int max = 0 ; for ( int i = 0 ; i < n ; i ++ ) mls [ i ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) for ( int j = 0 ; j < i ; j ++ ) if ( Math . Abs ( arr [ i ] - arr [ j ] ) <= 1 && mls [ i ] < mls [ j ] + 1 ) mls [ i ] = mls [ j ] + 1 ; for ( int i = 0 ; i < n ; i ++ ) if ( max < mls [ i ] ) max = mls [ i ] ; return max ; } public static void Main ( ) { int [ ] arr = { 2 , 5 , 6 , 3 , 7 , 6 , 5 , 8 } ; int n = arr . Length ; Console . Write ( " Maximum ▁ length ▁ subsequence ▁ = ▁ " + maxLenSub ( arr , n ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static bool findWinner ( int x , int y , int n ) { bool [ ] dp = new bool [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) dp [ i ] = false ; dp [ 0 ] = false ; dp [ 1 ] = true ; for ( int i = 2 ; i <= n ; i ++ ) { if ( i - 1 >= 0 && dp [ i - 1 ] == false ) dp [ i ] = true ; else if ( i - x >= 0 && dp [ i - x ] == false ) dp [ i ] = true ; else if ( i - y >= 0 && dp [ i - y ] == false ) dp [ i ] = true ; else dp [ i ] = false ; } return dp [ n ] ; } public static void Main ( ) { int x = 3 , y = 4 , n = 5 ; if ( findWinner ( x , y , n ) == true ) Console . WriteLine ( ' A ' ) ; else Console . WriteLine ( ' B ' ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxGameByWinner ( int N ) { int [ ] dp = new int [ N ] ; dp [ 0 ] = 1 ; dp [ 1 ] = 2 ; int i = 2 ; do { dp [ i ] = dp [ i - 1 ] + dp [ i - 2 ] ; } while ( dp [ i ++ ] <= N ) ; return ( i - 2 ) ; } public static void Main ( ) { int N = 10 ; Console . Write ( maxGameByWinner ( N ) ) ; } }

Index/key variables: N, i
Accumulator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minRemove ( int [ ] arr , int n ) { int [ ] LIS = new int [ n ] ; int len = 0 ; for ( int i = 0 ; i < n ; i ++ ) LIS [ i ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { if ( arr [ i ] > arr [ j ] && ( i - j ) <= ( arr [ i ] - arr [ j ] ) ) LIS [ i ] = Math . Max ( LIS [ i ] , LIS [ j ] + 1 ) ; } len = Math . Max ( len , LIS [ i ] ) ; } return n - len ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 6 , 5 , 4 } ; int n = arr . Length ; Console . WriteLine ( minRemove ( arr , n ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int countTransformation ( string a , string b ) { int n = a . Length , m = b . Length ; if ( m == 0 ) return 1 ; int [ , ] dp = new int [ m , n ] ; for ( int i = 0 ; i < m ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) dp [ i , j ] = 0 ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { if ( i == 0 ) { if ( j == 0 ) dp [ i , j ] = ( a [ j ] == b [ i ] ) ? 1 : 0 ; else if ( a [ j ] == b [ i ] ) dp [ i , j ] = dp [ i , j - 1 ] + 1 ; else dp [ i , j ] = dp [ i , j - 1 ] ; } else { if ( a [ j ] == b [ i ] ) dp [ i , j ] = dp [ i , j - 1 ] + dp [ i - 1 , j - 1 ] ; else dp [ i , j ] = dp [ i , j - 1 ] ; } } } return dp [ m - 1 , n - 1 ] ; } static void Main ( ) { string a = " abcccdf " , b = " abccdf " ; Console . Write ( countTransformation ( a , b ) ) ; } }

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 max = 100000 ; static int baseconversion ( int [ ] arr , int num , int bas ) { int i = 0 , rem ; if ( num == 0 ) { return 0 ; } while ( num > 0 ) { rem = num % bas ; arr [ i ++ ] = rem ; num /= bas ; } return i ; } public static void Main ( ) { int [ ] arr = new int [ max ] ; int n = 10 ; int size = baseconversion ( arr , n - 1 , 6 ) ; if ( size == 0 ) Console . Write ( size ) ; for ( int i = size - 1 ; i >= 0 ; i -- ) { Console . Write ( arr [ i ] ) ; } } }

Index/key variables: i, max
Accumulator variables: i, num
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int MAX = 1000 ; static int maxSubsequenceSubstring ( string x , string y , int n , int m ) { int [ , ] dp = new int [ MAX , MAX ] ; for ( int i = 0 ; i <= m ; i ++ ) for ( int j = 0 ; j <= n ; j ++ ) dp [ i , j ] = 0 ; for ( int i = 1 ; i <= m ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { if ( x [ j - 1 ] == y [ i - 1 ] ) dp [ i , j ] = 1 + dp [ i - 1 , j - 1 ] ; else dp [ i , j ] = dp [ i , j - 1 ] ; } } int ans = 0 ; for ( int i = 1 ; i <= m ; i ++ ) ans = Math . Max ( ans , dp [ i , n ] ) ; return ans ; } public static void Main ( ) { string x = " ABCD " ; string y = " BACDBDCD " ; int n = x . Length , m = y . Length ; Console . WriteLine ( maxSubsequenceSubstring ( x , y , n , m ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static int minPyramidCost ( int [ ] arr , int N ) { int [ ] left = new int [ N ] ; int [ ] right = new int [ N ] ; left [ 0 ] = Math . Min ( arr [ 0 ] , 1 ) ; for ( int i = 1 ; i < N ; ++ i ) left [ i ] = Math . Min ( arr [ i ] , Math . Min ( left [ i - 1 ] + 1 , i + 1 ) ) ; right [ N - 1 ] = Math . Min ( arr [ N - 1 ] , 1 ) ; for ( int i = N - 2 ; i >= 0 ; -- i ) right [ i ] = Math . Min ( arr [ i ] , Math . Min ( right [ i + 1 ] + 1 , N - i ) ) ; int [ ] tot = new int [ N ] ; for ( int i = 0 ; i < N ; ++ i ) tot [ i ] = Math . Min ( right [ i ] , left [ i ] ) ; int max_ind = 0 ; for ( int i = 0 ; i < N ; ++ i ) if ( tot [ i ] > tot [ max_ind ] ) max_ind = i ; int cost = 0 ; int height = tot [ max_ind ] ; for ( int x = max_ind ; x >= 0 ; -- x ) { cost += arr [ x ] - height ; if ( height > 0 ) -- height ; } height = tot [ max_ind ] - 1 ; for ( int x = max_ind + 1 ; x < N ; ++ x ) { cost += arr [ x ] - height ; if ( height > 0 ) -- height ; } return cost ; } static public void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 2 , 1 } ; int N = arr . Length ; Console . WriteLine ( minPyramidCost ( arr , N ) ) ; } }

Index/key variables: N, i, max_ind, x
Accumulator variables: cost
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; class GFG { public static int maxSum ( int [ , ] grid , int n ) { int incl = Math . Max ( grid [ 0 , 0 ] , grid [ 1 , 0 ] ) ; int excl = 0 , excl_new ; for ( int i = 1 ; i < n ; i ++ ) { excl_new = Math . Max ( excl , incl ) ; incl = excl + Math . Max ( grid [ 0 , i ] , grid [ 1 , i ] ) ; excl = excl_new ; } return Math . Max ( excl , incl ) ; } public static void Main ( String [ ] args ) { int [ , ] grid = { { 1 , 2 , 3 , 4 , 5 } , { 6 , 7 , 8 , 9 , 10 } } ; int n = 5 ; Console . Write ( maxSum ( grid , n ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GfG { static int minInsertionStepToSortArray ( int [ ] arr , int N ) { int [ ] lis = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) lis [ i ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) for ( int j = 0 ; j < i ; j ++ ) if ( arr [ i ] >= arr [ j ] && lis [ i ] < lis [ j ] + 1 ) lis [ i ] = lis [ j ] + 1 ; int max = 0 ; for ( int i = 0 ; i < N ; i ++ ) if ( max < lis [ i ] ) max = lis [ i ] ; return ( N - max ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 5 , 1 , 4 , 7 , 6 } ; int N = arr . Length ; Console . Write ( minInsertionStepToSortArray ( arr , N ) ) ; } }

Index/key variables: N, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GfG
C# program:
using System ; public class GFG { static int NO_OF_CHARS = 256 ; static void printDistinct ( String str ) { int [ ] count = new int [ NO_OF_CHARS ] ; int i ; for ( i = 0 ; i < str . Length ; i ++ ) if ( str [ i ] != ' ▁ ' ) count [ ( int ) str [ i ] ] ++ ; int n = i ; for ( i = 0 ; i < n ; i ++ ) if ( count [ ( int ) str [ i ] ] == 1 ) Console . Write ( str [ i ] ) ; } public static void Main ( ) { String str = " GeeksforGeeks " ; printDistinct ( str ) ; } }

Index/key variables: NO_OF_CHARS, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int MAX = 1005 ; static int shortestSeq ( char [ ] S , char [ ] T , int m , int n ) { if ( m == 0 ) return MAX ; if ( n <= 0 ) return 1 ; int k ; for ( k = 0 ; k < n ; k ++ ) if ( T [ k ] == S [ 0 ] ) break ; if ( k == n ) return 1 ; char [ ] St1 = new Char [ S . Length - 1 ] ; Array . Copy ( S , 1 , St1 , 0 , S . Length - 1 ) ; char [ ] St2 = new Char [ S . Length - 1 ] ; Array . Copy ( S , 1 , St2 , 0 , S . Length - 1 ) ; char [ ] Tt1 = new Char [ T . Length - ( k + 1 ) ] ; Array . Copy ( T , k + 1 , Tt1 , 0 , T . Length - ( k + 1 ) ) ; return Math . Min ( shortestSeq ( St1 , T , m - 1 , n ) , 1 + shortestSeq ( St2 , Tt1 , m - 1 , n - k - 1 ) ) ; } public static void Main ( String [ ] args ) { char [ ] S = " babab " . ToCharArray ( ) ; char [ ] T = " babba " . ToCharArray ( ) ; int m = S . Length , n = T . Length ; int ans = shortestSeq ( S , T , m , n ) ; if ( ans >= MAX ) ans = - 1 ; Console . Write ( " Length ▁ of ▁ shortest ▁ subsequence ▁ is : ▁ " + ans + " STRNEWLINE " ) ; } }

Index/key variables: k
Accumulator variables: k
Iterator variables: k
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int MAX = 1005 ; static int shortestSeq ( char [ ] S , char [ ] T ) { int m = S . Length , n = T . Length ; int [ , ] dp = new int [ m + 1 , n + 1 ] ; for ( int i = 0 ; i <= m ; i ++ ) { dp [ i , 0 ] = 1 ; } for ( int i = 0 ; i <= n ; i ++ ) { dp [ 0 , i ] = MAX ; } for ( int i = 1 ; i <= m ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { char ch = S [ i - 1 ] ; int k ; for ( k = j - 1 ; k >= 0 ; k -- ) { if ( T [ k ] == ch ) { break ; } } if ( k == - 1 ) { dp [ i , j ] = 1 ; } else { dp [ i , j ] = Math . Min ( dp [ i - 1 , j ] , dp [ i - 1 , k ] + 1 ) ; } } } int ans = dp [ m , n ] ; if ( ans >= MAX ) { ans = - 1 ; } return ans ; } public static void Main ( String [ ] args ) { char [ ] S = " babab " . ToCharArray ( ) ; char [ ] T = " babba " . ToCharArray ( ) ; int m = S . Length , n = T . Length ; Console . WriteLine ( " Length ▁ of ▁ shortest " + " subsequence ▁ is ▁ : ▁ " + shortestSeq ( S , T ) ) ; } }

Index/key variables: k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static void countWaysToJump ( int [ ] arr , int n ) { int [ ] count_jump = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) count_jump [ i ] = 0 ; for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( arr [ i ] >= n - i - 1 ) count_jump [ i ] ++ ; for ( int j = i + 1 ; j < n - 1 && j <= arr [ i ] + i ; j ++ ) if ( count_jump [ j ] != - 1 ) count_jump [ i ] += count_jump [ j ] ; if ( count_jump [ i ] == 0 ) count_jump [ i ] = - 1 ; } for ( int i = 0 ; i < n ; i ++ ) Console . Write ( count_jump [ i ] + " ▁ " ) ; } public static void Main ( ) { int [ ] arr = { 1 , 3 , 5 , 8 , 9 , 1 , 0 , 7 , 6 , 8 , 9 } ; int n = arr . Length ; countWaysToJump ( arr , n ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int minStepToDeleteString ( string str ) { int N = str . Length ; int [ , ] dp = new int [ N + 1 , N + 1 ] ; for ( int i = 0 ; i <= N ; i ++ ) for ( int j = 0 ; j <= N ; j ++ ) dp [ i , j ] = 0 ; for ( int len = 1 ; len <= N ; len ++ ) { for ( int i = 0 , j = len - 1 ; j < N ; i ++ , j ++ ) { if ( len == 1 ) dp [ i , j ] = 1 ; else { dp [ i , j ] = 1 + dp [ i + 1 , j ] ; if ( str [ i ] == str [ i + 1 ] ) dp [ i , j ] = Math . Min ( 1 + dp [ i + 2 , j ] , dp [ i , j ] ) ; for ( int K = i + 2 ; K <= j ; K ++ ) if ( str [ i ] == str [ K ] ) dp [ i , j ] = Math . Min ( dp [ i + 1 , K - 1 ] + dp [ K + 1 , j ] , dp [ i , j ] ) ; } } } return dp [ 0 , N - 1 ] ; } public static void Main ( ) { string str = "2553432" ; Console . Write ( minStepToDeleteString ( str ) ) ; } }

Index/key variables: K, i
Accumulator variables: K, i, j, len
Iterator variables: K, i, j, len
Class/struct names: GFG
C# program:
using System ; class GFG { static int inf = 1000000000 ; static int ans = inf ; static void solve ( int i , int par , int [ ] a , int n , int k , int current_ans ) { if ( par > k ) return ; if ( par == k && i == n - 1 ) { ans = Math . Min ( ans , current_ans ) ; return ; } for ( int j = i + 1 ; j < n ; j ++ ) solve ( j , par + 1 , a , n , k , current_ans + ( a [ j ] - a [ i + 1 ] ) * ( a [ j ] - a [ i + 1 ] ) ) ; } public static void Main ( ) { int k = 2 ; int [ ] a = { 1 , 5 , 8 , 10 } ; int n = a . Length ; solve ( - 1 , 0 , a , n , k , 0 ) ; Console . Write ( ans ) ; } }

Index/key variables: j
Accumulator variables: j
Iterator variables: j
Class/struct names: GFG
C# program:
using System ; class GFG { static int getMinSteps ( int n , int [ ] memo ) { if ( n == 1 ) return 0 ; if ( memo [ n ] != - 1 ) return memo [ n ] ; int res = getMinSteps ( n - 1 , memo ) ; if ( n % 2 == 0 ) res = Math . Min ( res , getMinSteps ( n / 2 , memo ) ) ; if ( n % 3 == 0 ) res = Math . Min ( res , getMinSteps ( n / 3 , memo ) ) ; memo [ n ] = 1 + res ; return memo [ n ] ; } static int getMinSteps ( int n ) { int [ ] memo = new int [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) memo [ i ] = - 1 ; return getMinSteps ( n , memo ) ; } public static void Main ( ) { int n = 10 ; Console . WriteLine ( getMinSteps ( n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int MAX = 1000 ; static int numofArray ( int n , int m ) { int [ , ] dp = new int [ MAX , MAX ] ; List < int > [ ] di = new List < int > [ MAX ] ; List < int > [ ] mu = new List < int > [ MAX ] ; for ( int i = 0 ; i < MAX ; i ++ ) { for ( int j = 0 ; j < MAX ; j ++ ) { dp [ i , j ] = 0 ; } } for ( int i = 0 ; i < MAX ; i ++ ) { di [ i ] = new List < int > ( ) ; mu [ i ] = new List < int > ( ) ; } for ( int i = 1 ; i <= m ; i ++ ) { for ( int j = 2 * i ; j <= m ; j += i ) { di [ j ] . Add ( i ) ; mu [ i ] . Add ( j ) ; } di [ i ] . Add ( i ) ; } for ( int i = 1 ; i <= m ; i ++ ) dp [ 1 , i ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= m ; j ++ ) { dp [ i , j ] = 0 ; foreach ( int x in di [ j ] ) dp [ i , j ] += dp [ i - 1 , x ] ; foreach ( int x in mu [ j ] ) dp [ i , j ] += dp [ i - 1 , x ] ; } } int ans = 0 ; for ( int i = 1 ; i <= m ; i ++ ) { ans += dp [ n , i ] ; di [ i ] . Clear ( ) ; mu [ i ] . Clear ( ) ; } return ans ; } public static void Main ( String [ ] args ) { int n = 3 , m = 3 ; Console . WriteLine ( numofArray ( n , m ) ) ; } }

Index/key variables: MAX, i, j
Accumulator variables: ans, i, j
Iterator variables: i, j, x
Class/struct names: GFG
C# program:
using System ; class GFG { public class Temple { public int L ; public int R ; } ; static int offeringNumber ( int n , int [ ] templeHeight ) { Temple [ ] chainSize = new Temple [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { chainSize [ i ] = new Temple ( ) ; chainSize [ i ] . L = - 1 ; chainSize [ i ] . R = - 1 ; } chainSize [ 0 ] . L = 1 ; chainSize [ n - 1 ] . R = 1 ; for ( int i = 1 ; i < n ; ++ i ) { if ( templeHeight [ i - 1 ] < templeHeight [ i ] ) chainSize [ i ] . L = chainSize [ i - 1 ] . L + 1 ; else chainSize [ i ] . L = 1 ; } for ( int i = n - 2 ; i >= 0 ; -- i ) { if ( templeHeight [ i + 1 ] < templeHeight [ i ] ) chainSize [ i ] . R = chainSize [ i + 1 ] . R + 1 ; else chainSize [ i ] . R = 1 ; } int sum = 0 ; for ( int i = 0 ; i < n ; ++ i ) sum += Math . Max ( chainSize [ i ] . L , chainSize [ i ] . R ) ; return sum ; } static void Main ( ) { int [ ] arr1 = { 1 , 2 , 2 } ; Console . Write ( offeringNumber ( 3 , arr1 ) + " STRNEWLINE " ) ; int [ ] arr2 = { 1 , 4 , 3 , 6 , 2 , 1 } ; Console . Write ( offeringNumber ( 6 , arr2 ) + " STRNEWLINE " ) ; } }

Index/key variables: i, n
Accumulator variables: sum
Iterator variables: i
Class/struct names: GFG, Temple
C# program:
using System ; public class GFG { static int stringReduction ( String str ) { int n = str . Length ; int [ ] count = new int [ 3 ] ; for ( int i = 0 ; i < n ; ++ i ) { count [ str [ i ] - ' a ' ] ++ ; } if ( count [ 0 ] == n count [ 1 ] == n count [ 2 ] == n ) { return n ; } if ( ( count [ 0 ] % 2 ) == ( count [ 1 ] % 2 ) && ( count [ 1 ] % 2 ) == ( count [ 2 ] % 2 ) ) { return 2 ; } return 1 ; } public static void Main ( ) { String str = " abcbbaacb " ; Console . WriteLine ( stringReduction ( str ) ) ; } }

Index/key variables: i
Iterator variables: i
Class/struct names: GFG