dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int MinimumCost ( int [ ] cost , int n , int W ) { List < int > val = new List < int > ( ) ; List < int > wt = new List < int > ( ) ; int size = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( cost [ i ] != - 1 ) { val . Add ( cost [ i ] ) ; wt . Add ( i + 1 ) ; size ++ ; } } n = size ; int [ , ] min_cost = new int [ n + 1 , W + 1 ] ; for ( int i = 0 ; i <= W ; i ++ ) min_cost [ 0 , i ] = int . MaxValue ; for ( int i = 1 ; i <= n ; i ++ ) min_cost [ i , 0 ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= W ; j ++ ) { if ( wt [ i - 1 ] > j ) min_cost [ i , j ] = min_cost [ i - 1 , j ] ; else min_cost [ i , j ] = Math . Min ( min_cost [ i - 1 , j ] , min_cost [ i , j - wt [ i - 1 ] ] + val [ i - 1 ] ) ; } } return ( min_cost [ n , W ] == int . MaxValue ) ? - 1 : min_cost [ n , W ] ; } public static void Main ( ) { int [ ] cost = { 1 , 2 , 3 , 4 , 5 } ; int W = 5 ; int n = cost . Length ; Console . WriteLine ( MinimumCost ( cost , n , W ) ) ; } }

Index/key variables: i
Accumulator variables: i, j, size
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int count ( string a , string b , int m , int n ) { if ( ( m == 0 && n == 0 ) n == 0 ) return 1 ; if ( m == 0 ) return 0 ; if ( a [ m - 1 ] == b [ n - 1 ] ) return count ( a , b , m - 1 , n - 1 ) + count ( a , b , m - 1 , n ) ; else return count ( a , b , m - 1 , n ) ; } public static void Main ( ) { string a = " GeeksforGeeks " ; string b = " Gks " ; Console . Write ( count ( a , b , a . Length , b . Length ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int lcs ( String X , String Y , int m , int n ) { int [ , ] L = new int [ m + 1 , n + 1 ] ; for ( int i = 0 ; i <= m ; i ++ ) { for ( int j = 0 ; j <= n ; j ++ ) { if ( i == 0 j == 0 ) L [ i , j ] = 0 ; else if ( X [ i - 1 ] == Y [ j - 1 ] ) L [ i , j ] = L [ i - 1 , j - 1 ] + 1 ; else L [ i , j ] = Math . Max ( L [ i - 1 , j ] , L [ i , j - 1 ] ) ; } } return L [ m , n ] ; } static int findMinCost ( String X , String Y , int costX , int costY ) { int m = X . Length ; int n = Y . Length ; int len_LCS ; len_LCS = lcs ( X , Y , m , n ) ; return costX * ( m - len_LCS ) + costY * ( n - len_LCS ) ; } public static void Main ( ) { String X = " ef " ; String Y = " gh " ; Console . Write ( " Minimum ▁ Cost ▁ to ▁ make ▁ two ▁ strings ▁ " + " ▁ identical ▁ is ▁ = ▁ " + findMinCost ( X , Y , 10 , 20 ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int N = 100 ; static int [ , ] L = new int [ N , N ] ; static HashSet < String > findLCS ( String X , String Y , int m , int n ) { HashSet < String > s = new HashSet < String > ( ) ; if ( m == 0 n == 0 ) { s . Add ( " " ) ; return s ; } if ( X [ m - 1 ] == Y [ n - 1 ] ) { HashSet < String > tmp = findLCS ( X , Y , m - 1 , n - 1 ) ; foreach ( String str in tmp ) s . Add ( str + X [ m - 1 ] ) ; } else { if ( L [ m - 1 , n ] >= L [ m , n - 1 ] ) s = findLCS ( X , Y , m - 1 , n ) ; if ( L [ m , n - 1 ] >= L [ m - 1 , n ] ) { HashSet < String > tmp = findLCS ( X , Y , m , n - 1 ) ; foreach ( String str in tmp ) s . Add ( str ) ; } } return s ; } static int LCS ( String X , String Y , int m , int n ) { for ( int i = 0 ; i <= m ; i ++ ) { for ( int j = 0 ; j <= n ; j ++ ) { if ( i == 0 j == 0 ) L [ i , j ] = 0 ; else if ( X [ i - 1 ] == Y [ j - 1 ] ) L [ i , j ] = L [ i - 1 , j - 1 ] + 1 ; else L [ i , j ] = Math . Max ( L [ i - 1 , j ] , L [ i , j - 1 ] ) ; } } return L [ m , n ] ; } public static void Main ( String [ ] args ) { String X = " AGTGATG " ; String Y = " GTTAG " ; int m = X . Length ; int n = Y . Length ; Console . WriteLine ( " LCS ▁ length ▁ is ▁ " + LCS ( X , Y , m , n ) ) ; HashSet < String > s = findLCS ( X , Y , m , n ) ; foreach ( String str in s ) Console . WriteLine ( str ) ; } }

Accumulator variables: i, j
Iterator variables: i, j, str
Class/struct names: GFG
C# program:
using System ; class GFG { static int countIntegralSolutions ( int n ) { int result = 0 ; for ( int i = 0 ; i <= n ; i ++ ) for ( int j = 0 ; j <= n - i ; j ++ ) for ( int k = 0 ; k <= ( n - i - j ) ; k ++ ) if ( i + j + k == n ) result ++ ; return result ; } public static void Main ( ) { int n = 3 ; Console . Write ( countIntegralSolutions ( n ) ) ; } }

Accumulator variables: i, j, k, result
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int countIntegralSolutions ( int n ) { return ( ( n + 1 ) * ( n + 2 ) ) / 2 ; } public static void Main ( String [ ] args ) { int n = 3 ; Console . Write ( countIntegralSolutions ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int maxLeftSubArraySum ( int [ ] a , int size , int [ ] sum ) { int max_so_far = a [ 0 ] ; int curr_max = a [ 0 ] ; sum [ 0 ] = max_so_far ; for ( int i = 1 ; i < size ; i ++ ) { curr_max = Math . Max ( a [ i ] , curr_max + a [ i ] ) ; max_so_far = Math . Max ( max_so_far , curr_max ) ; sum [ i ] = max_so_far ; } return max_so_far ; } static int maxRightSubArraySum ( int [ ] a , int n , int [ ] sum ) { int max_so_far = a [ n ] ; int curr_max = a [ n ] ; sum [ n ] = max_so_far ; for ( int i = n - 1 ; i >= 0 ; i -- ) { curr_max = Math . Max ( a [ i ] , curr_max + a [ i ] ) ; max_so_far = Math . Max ( max_so_far , curr_max ) ; sum [ i ] = max_so_far ; } return max_so_far ; } static int findMaxAbsDiff ( int [ ] arr , int n ) { int [ ] leftMax = new int [ n ] ; maxLeftSubArraySum ( arr , n , leftMax ) ; int [ ] rightMax = new int [ n ] ; maxRightSubArraySum ( arr , n - 1 , rightMax ) ; int [ ] invertArr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) invertArr [ i ] = - arr [ i ] ; int [ ] leftMin = new int [ n ] ; maxLeftSubArraySum ( invertArr , n , leftMin ) ; for ( int i = 0 ; i < n ; i ++ ) leftMin [ i ] = - leftMin [ i ] ; int [ ] rightMin = new int [ n ] ; maxRightSubArraySum ( invertArr , n - 1 , rightMin ) ; for ( int i = 0 ; i < n ; i ++ ) rightMin [ i ] = - rightMin [ i ] ; int result = - 2147483648 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int absValue = Math . Max ( Math . Abs ( leftMax [ i ] - rightMin [ i + 1 ] ) , Math . Abs ( leftMin [ i ] - rightMax [ i + 1 ] ) ) ; if ( absValue > result ) result = absValue ; } return result ; } public static void Main ( ) { int [ ] a = { - 2 , - 3 , 4 , - 1 , - 2 , 1 , 5 , - 3 } ; int n = a . Length ; Console . Write ( findMaxAbsDiff ( a , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countWays ( int p , int q , int r , int last ) { if ( p < 0 q < 0 r < 0 ) return 0 ; if ( p == 1 && q == 0 && r == 0 && last == 0 ) return 1 ; if ( p == 0 && q == 1 && r == 0 && last == 1 ) return 1 ; if ( p == 0 && q == 0 && r == 1 && last == 2 ) return 1 ; if ( last == 0 ) return countWays ( p - 1 , q , r , 1 ) + countWays ( p - 1 , q , r , 2 ) ; if ( last == 1 ) return countWays ( p , q - 1 , r , 0 ) + countWays ( p , q - 1 , r , 2 ) ; if ( last == 2 ) return countWays ( p , q , r - 1 , 0 ) + countWays ( p , q , r - 1 , 1 ) ; return 0 ; } static int countUtil ( int p , int q , int r ) { return countWays ( p , q , r , 0 ) + countWays ( p , q , r , 1 ) + countWays ( p , q , r , 2 ) ; } public static void Main ( ) { int p = 1 , q = 1 , r = 1 ; Console . Write ( countUtil ( p , q , r ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public static int findMinRec ( int [ ] arr , int i , int sumCalculated , int sumTotal ) { if ( i == 0 ) return Math . Abs ( ( sumTotal - sumCalculated ) - sumCalculated ) ; return Math . Min ( findMinRec ( arr , i - 1 , sumCalculated + arr [ i - 1 ] , sumTotal ) , findMinRec ( arr , i - 1 , sumCalculated , sumTotal ) ) ; } public static int findMin ( int [ ] arr , int n ) { int sumTotal = 0 ; for ( int i = 0 ; i < n ; i ++ ) sumTotal += arr [ i ] ; return findMinRec ( arr , n , 0 , sumTotal ) ; } public static void Main ( ) { int [ ] arr = { 3 , 1 , 4 , 2 , 2 , 1 } ; int n = arr . Length ; Console . Write ( " The ▁ minimum ▁ difference " + " ▁ between ▁ two ▁ sets ▁ is ▁ " + findMin ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, sumTotal
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int minDifference ( int [ ] arr , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; int y = sum / 2 + 1 ; bool [ ] dp = new bool [ y ] ; bool [ ] dd = new bool [ y ] ; for ( int i = 0 ; i < y ; i ++ ) { dp [ i ] = dd [ i ] = false ; } dd [ 0 ] = true ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j + arr [ i ] < y ; j ++ ) { if ( dp [ j ] ) dd [ j + arr [ i ] ] = true ; } for ( int j = 0 ; j < y ; j ++ ) { if ( dd [ j ] ) dp [ j ] = true ; } } for ( int i = y - 1 ; i >= 0 ; i -- ) { if ( dp [ i ] ) return ( sum - 2 * i ) ; } return 0 ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 6 , 11 , 5 } ; int n = arr . Length ; Console . Write ( " The ▁ Minimum ▁ difference ▁ of ▁ 2 ▁ sets ▁ is ▁ " + minDifference ( arr , n ) + ' STRNEWLINE ' ) ; } }

Index/key variables: i, j, y
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static int countP ( int n , int k ) { if ( n == 0 k == 0 k > n ) return 0 ; if ( k == 1 k == n ) return 1 ; return ( k * countP ( n - 1 , k ) + countP ( n - 1 , k - 1 ) ) ; } public static void Main ( ) { Console . WriteLine ( countP ( 3 , 2 ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int countP ( int n , int k ) { int [ , ] dp = new int [ n + 1 , k + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) dp [ i , 0 ] = 0 ; for ( int i = 0 ; i <= k ; i ++ ) dp [ 0 , k ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) for ( int j = 1 ; j <= k ; j ++ ) if ( j == 1 i == j ) dp [ i , j ] = 1 ; else dp [ i , j ] = j * dp [ i - 1 , j ] + dp [ i - 1 , j - 1 ] ; return dp [ n , k ] ; } public static void Main ( ) { Console . Write ( countP ( 5 , 2 ) ) ; } }

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

Class/struct names: GFG
C# program:
using System ; class GFG { static int printCountDP ( int dist ) { int [ ] ways = new int [ 3 ] ; int n = dist ; ways [ 0 ] = 1 ; ways [ 1 ] = 1 ; ways [ 2 ] = 2 ; for ( int i = 3 ; i <= n ; i ++ ) ways [ i % 3 ] = ways [ ( i - 1 ) % 3 ] + ways [ ( i - 2 ) % 3 ] + ways [ ( i - 3 ) % 3 ] ; return ways [ n % 3 ] ; } public static void Main ( String [ ] arg ) { int dist = 4 ; Console . Write ( printCountDP ( dist ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int countNumbersWith4 ( int n ) { int result = 0 ; for ( int x = 1 ; x <= n ; x ++ ) result += has4 ( x ) ? 1 : 0 ; return result ; } static bool has4 ( int x ) { while ( x != 0 ) { if ( x % 10 == 4 ) return true ; x = x / 10 ; } return false ; } public static void Main ( ) { int n = 328 ; Console . WriteLine ( " Count ▁ of ▁ numbers ▁ from ▁ 1 ▁ to ▁ " + " ▁ that ▁ have ▁ 4 ▁ as ▁ a ▁ a ▁ digit ▁ is ▁ " + countNumbersWith4 ( n ) ) ; } }

Accumulator variables: result, x
Iterator variables: x
Class/struct names: GFG
C# program:
using System ; class GFG { static int countNumbersWith4 ( int n ) { if ( n < 4 ) return 0 ; int d = ( int ) Math . Log10 ( n ) ; int [ ] a = new int [ d + 2 ] ; a [ 0 ] = 0 ; a [ 1 ] = 1 ; for ( int i = 2 ; i <= d ; i ++ ) a [ i ] = a [ i - 1 ] * 9 + ( int ) Math . Ceiling ( Math . Pow ( 10 , i - 1 ) ) ; int p = ( int ) Math . Ceiling ( Math . Pow ( 10 , d ) ) ; int msd = n / p ; if ( msd == 4 ) return ( msd ) * a [ d ] + ( n % p ) + 1 ; if ( msd > 4 ) return ( msd - 1 ) * a [ d ] + p + countNumbersWith4 ( n % p ) ; return ( msd ) * a [ d ] + countNumbersWith4 ( n % p ) ; } static void Main ( ) { int n = 328 ; Console . WriteLine ( " Count ▁ of ▁ numbers ▁ from ▁ 1 ▁ to ▁ " + n + " ▁ that ▁ have ▁ 4 ▁ as ▁ a ▁ digit ▁ is ▁ " + countNumbersWith4 ( n ) ) ; } }

Index/key variables: d, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int minRemovalsDP ( int [ ] arr , int n ) { int longest_start = - 1 , longest_end = 0 ; for ( int start = 0 ; start < n ; start ++ ) { int min = int . MaxValue , max = int . MinValue ; for ( int end = start ; end < n ; end ++ ) { int val = arr [ end ] ; if ( val < min ) { min = val ; } if ( val > max ) { max = val ; } if ( 2 * min <= max ) { break ; } if ( end - start > longest_end - longest_start longest_start == - 1 ) { longest_start = start ; longest_end = end ; } } } if ( longest_start == - 1 ) { return n ; } return ( n - ( longest_end - longest_start + 1 ) ) ; } public static void Main ( ) { int [ ] arr = { 4 , 5 , 100 , 9 , 10 , 11 , 12 , 15 , 200 } ; int n = arr . Length ; Console . WriteLine ( minRemovalsDP ( arr , n ) ) ; } }

Index/key variables: end
Accumulator variables: end, start
Iterator variables: end, start
Class/struct names: GFG
C# program:
using System ; public class GFG { static int optimalStrategyOfGame ( int [ ] arr , int n ) { int [ , ] table = new int [ n , n ] ; int gap , i , j , x , y , z ; for ( gap = 0 ; gap < n ; ++ gap ) { for ( i = 0 , j = gap ; j < n ; ++ i , ++ j ) { x = ( ( i + 2 ) <= j ) ? table [ i + 2 , j ] : 0 ; y = ( ( i + 1 ) <= ( j - 1 ) ) ? table [ i + 1 , j - 1 ] : 0 ; z = ( i <= ( j - 2 ) ) ? table [ i , j - 2 ] : 0 ; table [ i , j ] = Math . Max ( arr [ i ] + Math . Min ( x , y ) , arr [ j ] + Math . Min ( y , z ) ) ; } } return table [ 0 , n - 1 ] ; } static public void Main ( ) { int [ ] arr1 = { 8 , 15 , 3 , 7 } ; int n = arr1 . Length ; Console . WriteLine ( " " + optimalStrategyOfGame ( arr1 , n ) ) ; int [ ] arr2 = { 2 , 2 , 2 , 2 } ; n = arr2 . Length ; Console . WriteLine ( " " + optimalStrategyOfGame ( arr2 , n ) ) ; int [ ] arr3 = { 20 , 30 , 2 , 2 , 2 , 10 } ; n = arr3 . Length ; Console . WriteLine ( " " + optimalStrategyOfGame ( arr3 , n ) ) ; } }

Index/key variables: i, j
Iterator variables: gap, i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSumIS ( int [ ] arr , int n ) { int i , j , max = 0 ; int [ ] msis = new int [ n ] ; for ( i = 0 ; i < n ; i ++ ) msis [ i ] = arr [ i ] ; for ( i = 1 ; i < n ; i ++ ) for ( j = 0 ; j < i ; j ++ ) if ( arr [ i ] > arr [ j ] && msis [ i ] < msis [ j ] + arr [ i ] ) msis [ i ] = msis [ j ] + arr [ i ] ; for ( i = 0 ; i < n ; i ++ ) if ( max < msis [ i ] ) max = msis [ i ] ; return max ; } public static void Main ( ) { int [ ] arr = new int [ ] { 1 , 101 , 2 , 3 , 100 , 4 , 5 } ; int n = arr . Length ; Console . WriteLine ( " Sum ▁ of ▁ maximum ▁ sum ▁ increasing ▁ " + " ▁ subsequence ▁ is ▁ " + maxSumIS ( 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 checkArray ( int [ ] arr , int N , int k ) { if ( N < 3 ) return - 1 ; int i , Sum = 0 , temp = 0 ; for ( i = 0 ; i < N ; i ++ ) Sum += arr [ i ] ; int R = ( k * k + k + 1 ) ; if ( Sum % R != 0 ) return 0 ; int Mid = k * ( Sum / R ) ; for ( i = 1 ; i < N - 1 ; i ++ ) { temp += arr [ i - 1 ] ; if ( arr [ i ] == Mid ) { if ( temp == Mid / k ) return i + 1 ; else return 0 ; } } return 0 ; } public static void Main ( string [ ] args ) { int [ ] arr = { 5 , 1 , 4 , 20 , 6 , 15 , 9 , 10 } ; int N = arr . Length ; int K = 2 ; Console . WriteLine ( checkArray ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: Sum, i, temp
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static void encodeString ( String str ) { String res = " " ; int [ ] small = new int [ 26 ] ; int [ ] capital = new int [ 26 ] ; int [ ] num = new int [ 10 ] ; for ( int i = 0 ; i < 26 ; i ++ ) { small [ i ] = 0 ; capital [ i ] = 0 ; } for ( int i = 0 ; i < 10 ; i ++ ) { num [ i ] = 0 ; } int n = str . Length ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] >= '0' && str [ i ] <= '9' ) { num [ str [ i ] - 48 ] = i ; } else if ( str [ i ] >= ' a ' && str [ i ] <= ' z ' ) { small [ str [ i ] - 97 ] = i ; } else if ( str [ i ] >= ' A ' && str [ i ] <= ' Z ' ) { capital [ str [ i ] - 65 ] = i ; } } for ( int i = 0 ; i < n ; i ++ ) { if ( ( str [ i ] >= ' a ' && str [ i ] <= ' z ' ) && small [ str [ i ] - 97 ] == i ) { int occ = str [ i ] - 96 ; while ( occ -- > 0 ) { res += str [ i ] ; } } else if ( ( str [ i ] >= ' A ' && str [ i ] <= ' Z ' ) && capital [ str [ i ] - 65 ] == i ) { int occ = str [ i ] - 64 ; while ( occ -- > 0 ) { res = res + str [ i ] ; } } else if ( ( str [ i ] >= '0' && str [ i ] <= '9' ) && num [ str [ i ] - 48 ] == i ) { int occ = str [ i ] - 48 ; while ( occ -- > 0 ) { res = res + str [ i ] ; } } else { res = res + str [ i ] ; } } Console . Write ( res ) ; } public static void Main ( String [ ] args ) { String str = " Ea2 , ▁ 0 , ▁ E " ; encodeString ( str ) ; } }

Index/key variables: i
Accumulator variables: i, occ, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static int minimumPalindromicStrings ( String S ) { int N = S . Length ; int [ ] freq = new int [ 26 ] ; for ( int i = 0 ; i < N ; i ++ ) { freq [ S [ i ] - ' a ' ] ++ ; } List < int > oddFreqchars = new List < int > ( ) ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] % 2 == 1 ) { oddFreqchars . Add ( i ) ; freq [ i ] -- ; } freq [ i ] /= 2 ; } List < String > ans = new List < String > ( ) ; if ( oddFreqchars . Count == 0 ) { String left = " " ; for ( int i = 0 ; i < 26 ; i ++ ) { for ( int j = 0 ; j < freq [ i ] ; j ++ ) { left += ( char ) ( i + ' a ' ) ; } } String right = left ; right = reverse ( right ) ; ans . Add ( left + right ) ; } else { String middle = " " ; int c = oddFreqchars [ oddFreqchars . Count - 1 ] ; oddFreqchars . RemoveAt ( oddFreqchars . Count - 1 ) ; middle += ( char ) ( c + ' a ' ) ; String left = " " ; for ( int i = 0 ; i < 26 ; i ++ ) { for ( int j = 0 ; j < freq [ i ] ; j ++ ) { left += ( char ) ( i + ' a ' ) ; } } String right = left ; right = reverse ( right ) ; ans . Add ( left + middle + right ) ; while ( oddFreqchars . Count != 0 ) { c = oddFreqchars [ oddFreqchars . Count - 1 ] ; oddFreqchars . RemoveAt ( oddFreqchars . Count - 1 ) ; middle = " " ; middle += ( char ) ( c + ' a ' ) ; ans . Add ( middle ) ; } } Console . Write ( " [ " ) ; for ( int i = 0 ; i < ans . Count ; i ++ ) { Console . Write ( ans [ i ] ) ; if ( i != ans . Count - 1 ) { Console . Write ( " , ▁ " ) ; } } Console . Write ( " ] " ) ; return 0 ; } 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 S = " geeksforgeeks " ; minimumPalindromicStrings ( S ) ; } }

Index/key variables: i, l, r
Accumulator variables: i, j, l, left, middle, r
Iterator variables: i, j, l
Class/struct names: GFG
C# program:
using System ; public class GFG { static void possibleEqualArray ( int [ ] A , int N ) { int [ ] pref = new int [ N ] ; pref [ 0 ] = A [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { pref [ i ] = pref [ i - 1 ] ^ A [ i ] ; } if ( pref [ N - 1 ] == 0 ) { Console . WriteLine ( " YES " ) ; return ; } int cur_xor = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { cur_xor ^= A [ i ] ; for ( int j = 0 ; j < i ; j ++ ) { if ( j != 0 ) { int middle_xor = pref [ j - 1 ] ^ pref [ i - 1 ] ; int left_xor = pref [ j - 1 ] ; int right_xor = cur_xor ; if ( left_xor == middle_xor && middle_xor == right_xor ) { Console . WriteLine ( " YES " ) ; return ; } } } } Console . WriteLine ( " NO " ) ; } public static void Main ( String [ ] args ) { int [ ] A = { 0 , 2 , 2 } ; int N = A . Length ; possibleEqualArray ( A , N ) ; } }

Index/key variables: N, i
Accumulator variables: cur_xor, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void GenerateArray ( int N , int X ) { int prev_xor = X ; for ( int i = 1 ; i <= N ; i ++ ) { Console . Write ( i ^ prev_xor ) ; if ( i != N ) { Console . Write ( " ▁ " ) ; } prev_xor = i ; } } static void Main ( ) { int N = 4 , X = 3 ; Console . Write ( " The ▁ generated ▁ array ▁ is ▁ " ) ; GenerateArray ( N , X ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void createGrid ( char [ , ] grid , bool is1 , int N , int M ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( is1 ) { grid [ i , j ] = '0' ; is1 = false ; } else { grid [ i , j ] = '1' ; is1 = true ; } } if ( M % 2 == 0 ) is1 = ! is1 ; } } public static bool testGrid ( char [ , ] testGrid , char [ , ] Grid , int N , int M ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( Grid [ i , j ] != ' * ' ) { if ( Grid [ i , j ] != testGrid [ i , j ] ) { return false ; } } } } return true ; } public static void printGrid ( char [ , ] grid , int N , int M ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { Console . Write ( grid [ i , j ] + " ▁ " ) ; } Console . WriteLine ( ) ; } } public static void findPossibleGrid ( int N , int M , char [ , ] grid ) { char [ , ] gridTest1 = new char [ N , 1001 ] ; char [ , ] gridTest2 = new char [ N , 1001 ] ; createGrid ( gridTest1 , true , N , M ) ; createGrid ( gridTest2 , false , N , M ) ; if ( testGrid ( gridTest1 , grid , N , M ) ) { Console . WriteLine ( " Yes " ) ; printGrid ( gridTest1 , N , M ) ; } else if ( testGrid ( gridTest2 , grid , N , M ) ) { Console . WriteLine ( " Yes " ) ; printGrid ( gridTest2 , N , M ) ; } else { Console . WriteLine ( " No " ) ; } } public static void Main ( ) { int N = 4 , M = 4 ; char [ , ] grid = { { ' * ' , ' * ' , '1' , '0' } , { ' * ' , ' * ' , ' * ' , ' * ' } , { ' * ' , ' * ' , ' * ' , ' * ' } , { ' * ' , ' * ' , '0' , '1' } } ; findPossibleGrid ( N , M , grid ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: is1
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int INF64 = ( int ) 1e8 ; static int N = 200 * 1000 + 13 ; static int n ; static int [ ] arr = new int [ N ] ; static int [ ] brr = new int [ N ] ; static void brute ( int ind , int l , int r ) { if ( ind == n / 2 ) { for ( int i = 0 ; i < ( int ) n ; i ++ ) Console . Write ( brr [ i ] + " ▁ " ) ; System . Environment . Exit ( 0 ) ; } for ( int i = l ; i <= arr [ ind ] / 2 ; ++ i ) if ( arr [ ind ] - i <= r ) { brr [ ind ] = i ; brr [ n - ind - 1 ] = arr [ ind ] - i ; brute ( ind + 1 , i , arr [ ind ] - i ) ; } } public static void Main ( ) { n = 2 ; n *= 2 ; arr [ 0 ] = 5 ; arr [ 1 ] = 6 ; brute ( 0 , 0 , INF64 ) ; } }

Index/key variables: N, i, ind
Accumulator variables: i, n
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int minCount ( int N , int K ) { int [ ] SmallestNumber = new int [ 10 ] ; int [ ] MinimumSteps = new int [ 10 ] ; for ( int i = 0 ; i <= 9 ; i ++ ) { SmallestNumber [ i ] = Int32 . MaxValue ; MinimumSteps [ i ] = Int32 . MaxValue ; } for ( int i = 1 ; i <= 10 ; i ++ ) { int num = K * i ; SmallestNumber [ num % 10 ] = Math . Min ( SmallestNumber [ num % 10 ] , num ) ; MinimumSteps [ num % 10 ] = Math . Min ( MinimumSteps [ num % 10 ] , i ) ; } if ( N < SmallestNumber [ N % 10 ] ) { return - 1 ; } else { return MinimumSteps [ N % 10 ] ; } } static public void Main ( ) { int N = 42 , K = 7 ; Console . Write ( minCount ( N , K ) ) ; } }

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