dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int nCr ( int n , int k ) { int [ , ] C = new int [ n + 1 , k + 1 ] ; int i , j ; for ( i = 0 ; i <= n ; i ++ ) { for ( j = 0 ; j <= Math . Min ( i , k ) ; j ++ ) { if ( j == 0 j == i ) C [ i , j ] = 1 ; else C [ i , j ] = C [ i - 1 , j - 1 ] + C [ i - 1 , j ] ; } } return C [ n , k ] ; } static double resultOfAllSubsets ( int [ ] arr , int N ) { double result = 0.0 ; int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) sum += arr [ i ] ; for ( int n = 1 ; n <= N ; n ++ ) result += ( double ) ( sum * ( nCr ( N - 1 , n - 1 ) ) ) / n ; return result ; } public static void Main ( ) { int [ ] arr = { 2 , 3 , 5 , 7 } ; int N = arr . Length ; Console . WriteLine ( resultOfAllSubsets ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, j, n, result, sum
Iterator variables: i, j, n
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] arr = { 100 , 1000 , 100 , 1000 , 1 } ; static int [ ] sum = new int [ 10000 ] ; static int maxSumWO3Consec ( int n ) { if ( sum [ n ] != - 1 ) return sum [ n ] ; if ( n == 0 ) return sum [ n ] = 0 ; if ( n == 1 ) return sum [ n ] = arr [ 0 ] ; if ( n == 2 ) return sum [ n ] = arr [ 1 ] + arr [ 0 ] ; return sum [ n ] = Math . Max ( Math . Max ( maxSumWO3Consec ( n - 1 ) , maxSumWO3Consec ( n - 2 ) + arr [ n ] ) , arr [ n ] + arr [ n - 1 ] + maxSumWO3Consec ( n - 3 ) ) ; } public static void Main ( String [ ] args ) { int n = arr . Length ; for ( int i = 0 ; i < sum . Length ; i ++ ) sum [ i ] = - 1 ; Console . WriteLine ( maxSumWO3Consec ( n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSumPairWithDifferenceLessThanK ( int [ ] arr , int N , int k ) { int maxSum = 0 ; Array . Sort ( arr ) ; for ( int i = N - 1 ; i > 0 ; -- i ) { if ( arr [ i ] - arr [ i - 1 ] < k ) { maxSum += arr [ i ] ; maxSum += arr [ i - 1 ] ; -- i ; } } return maxSum ; } public static void Main ( ) { int [ ] arr = { 3 , 5 , 10 , 15 , 17 , 12 , 9 } ; int N = arr . Length ; int K = 4 ; Console . Write ( maxSumPairWithDifferenceLessThanK ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: maxSum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countGroups ( int position , int previous_sum , int length , String num ) { if ( position == length ) return 1 ; int res = 0 ; int sum = 0 ; for ( int i = position ; i < length ; i ++ ) { sum += ( num [ i ] - '0' ) ; if ( sum >= previous_sum ) res += countGroups ( i + 1 , sum , length , num ) ; } return res ; } public static void Main ( ) { String num = "1119" ; int len = num . Length ; Console . Write ( countGroups ( 0 , 0 , len , num ) ) ; } }

Index/key variables: i
Accumulator variables: i, res, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 40 ; static int [ , ] dp = new int [ MAX , 9 * MAX + 1 ] ; static int countGroups ( int position , int previous_sum , int length , char [ ] num ) { if ( position == length ) return 1 ; if ( dp [ position , previous_sum ] != - 1 ) return dp [ position , previous_sum ] ; dp [ position , previous_sum ] = 0 ; int res = 0 ; int sum = 0 ; for ( int i = position ; i < length ; i ++ ) { sum += ( num [ i ] - '0' ) ; if ( sum >= previous_sum ) res += countGroups ( i + 1 , sum , length , num ) ; } dp [ position , previous_sum ] = res ; return res ; } static void Main ( ) { char [ ] num = { '1' , '1' , '1' , '9' } ; int len = num . Length ; for ( int i = 0 ; i < MAX ; i ++ ) for ( int j = 0 ; j < 9 * MAX + 1 ; j ++ ) dp [ i , j ] = - 1 ; Console . Write ( countGroups ( 0 , 0 , len , num ) ) ; } }

Index/key variables: i
Accumulator variables: i, j, res, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int KnapSack ( int [ ] val , int [ ] wt , int n , int W ) { int [ ] dp = new int [ W + 1 ] ; for ( int i = 0 ; i < W + 1 ; i ++ ) dp [ i ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = W ; j >= wt [ i ] ; j -- ) dp [ j ] = Math . Max ( dp [ j ] , val [ i ] + dp [ j - wt [ i ] ] ) ; return dp [ W ] ; } public static void Main ( String [ ] args ) { int [ ] val = { 7 , 8 , 4 } ; int [ ] wt = { 3 , 8 , 6 } ; int W = 10 , n = 3 ; Console . WriteLine ( KnapSack ( val , wt , n , W ) ) ; } }

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

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int lenOfLongestGP ( int [ ] Set , int n ) { if ( n < 2 ) { return n ; } if ( n == 2 ) { return ( Set [ 1 ] % Set [ 0 ] == 0 ? 2 : 1 ) ; } Array . Sort ( Set ) ; int [ , ] L = new int [ n , n ] ; int llgp = 1 ; for ( int i = 0 ; i < n - 1 ; ++ i ) { if ( Set [ n - 1 ] % Set [ i ] == 0 ) { L [ i , n - 1 ] = 2 ; if ( 2 > llgp ) llgp = 2 ; } else { L [ i , n - 1 ] = 1 ; } } L [ n - 1 , n - 1 ] = 1 ; for ( int j = n - 2 ; j >= 1 ; -- j ) { int i = j - 1 , k = j + 1 ; while ( i >= 0 && k <= n - 1 ) { if ( Set [ i ] * Set [ k ] < Set [ j ] * Set [ j ] ) { ++ k ; } else if ( Set [ i ] * Set [ k ] > Set [ j ] * Set [ j ] ) { if ( Set [ j ] % Set [ i ] == 0 ) { L [ i , j ] = 2 ; if ( 2 > llgp ) llgp = 2 ; } else { L [ i , j ] = 1 ; } -- i ; } else { if ( Set [ j ] % Set [ i ] == 0 ) { L [ i , j ] = L [ j , k ] + 1 ; if ( L [ i , j ] > llgp ) { llgp = L [ i , j ] ; } } else { L [ i , j ] = 1 ; } -- i ; ++ k ; } } while ( i >= 0 ) { if ( Set [ j ] % Set [ i ] == 0 ) { L [ i , j ] = 2 ; if ( 2 > llgp ) llgp = 2 ; } else { L [ i , j ] = 1 ; } -- i ; } } return llgp ; } public static void Main ( String [ ] args ) { int [ ] set1 = { 1 , 3 , 9 , 27 , 81 , 243 } ; int n1 = set1 . Length ; Console . Write ( lenOfLongestGP ( set1 , n1 ) + " STRNEWLINE " ) ; int [ ] set2 = { 1 , 3 , 4 , 9 , 7 , 27 } ; int n2 = set2 . Length ; Console . Write ( lenOfLongestGP ( set2 , n2 ) + " STRNEWLINE " ) ; int [ ] set3 = { 2 , 3 , 5 , 7 , 11 , 13 } ; int n3 = set3 . Length ; Console . Write ( lenOfLongestGP ( set3 , n3 ) + " STRNEWLINE " ) ; } }

Index/key variables: i, j, k
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Linq ; using System . Collections . Generic ; class GFG { static void print ( List < int > arr , int size ) { for ( int i = 0 ; i < size ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } static void printLBS ( int [ ] arr , int n ) { List < int > [ ] LIS = new List < int > [ n ] ; for ( int i = 0 ; i < n ; i ++ ) LIS [ i ] = new List < int > ( ) ; LIS [ 0 ] . Add ( arr [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { if ( ( arr [ i ] > arr [ j ] ) && LIS [ j ] . Count > LIS [ i ] . Count ) { foreach ( int k in LIS [ j ] ) if ( ! LIS [ i ] . Contains ( k ) ) LIS [ i ] . Add ( k ) ; } } LIS [ i ] . Add ( arr [ i ] ) ; } List < int > [ ] LDS = new List < int > [ n ] ; for ( int i = 0 ; i < n ; i ++ ) LDS [ i ] = new List < int > ( ) ; LDS [ n - 1 ] . Add ( arr [ n - 1 ] ) ; for ( int i = n - 2 ; i >= 0 ; i -- ) { for ( int j = n - 1 ; j > i ; j -- ) { if ( arr [ j ] < arr [ i ] && LDS [ j ] . Count > LDS [ i ] . Count ) foreach ( int k in LDS [ j ] ) if ( ! LDS [ i ] . Contains ( k ) ) LDS [ i ] . Add ( k ) ; } LDS [ i ] . Add ( arr [ i ] ) ; } for ( int i = 0 ; i < n ; i ++ ) LDS [ i ] . Reverse ( ) ; int max = 0 ; int maxIndex = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( LIS [ i ] . Count + LDS [ i ] . Count - 1 > max ) { max = LIS [ i ] . Count + LDS [ i ] . Count - 1 ; maxIndex = i ; } } print ( LIS [ maxIndex ] , LIS [ maxIndex ] . Count - 1 ) ; print ( LDS [ maxIndex ] , LDS [ maxIndex ] . Count ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 11 , 2 , 10 , 4 , 5 , 2 , 1 } ; int n = arr . Length ; printLBS ( arr , n ) ; } }

Index/key variables: i, j, maxIndex, n
Accumulator variables: i, j
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int isKPalDP ( string str1 , string str2 , int m , int n ) { int [ , ] dp = new int [ m + 1 , n + 1 ] ; for ( int i = 0 ; i <= m ; i ++ ) { for ( int j = 0 ; j <= n ; j ++ ) { if ( i == 0 ) { dp [ i , j ] = j ; } else if ( j == 0 ) { dp [ i , j ] = i ; } else if ( str1 [ i - 1 ] == str2 [ j - 1 ] ) { dp [ i , j ] = dp [ i - 1 , j - 1 ] ; } else { dp [ i , j ] = 1 + Math . Min ( dp [ i - 1 , j ] , dp [ i , j - 1 ] ) ; } } } return dp [ m , n ] ; } static bool isKPal ( string str , int k ) { string revStr = str ; revStr = reverse ( revStr ) ; int len = str . Length ; return ( isKPalDP ( str , revStr , len , len ) <= k * 2 ) ; } static string reverse ( string str ) { char [ ] sb = str . ToCharArray ( ) ; Array . Reverse ( sb ) ; return new string ( sb ) ; } static void Main ( ) { string str = " acdcb " ; int k = 2 ; if ( isKPal ( str , k ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static int lcs ( string X , string Y ) { int m = X . Length , n = Y . Length ; int [ , ] L = new int [ 2 , n + 1 ] ; int bi = 0 ; for ( int i = 0 ; i <= m ; i ++ ) { bi = i & 1 ; for ( int j = 0 ; j <= n ; j ++ ) { if ( i == 0 j == 0 ) L [ bi , j ] = 0 ; else if ( X [ i - 1 ] == Y [ j - 1 ] ) L [ bi , j ] = L [ 1 - bi , j - 1 ] + 1 ; else L [ bi , j ] = Math . Max ( L [ 1 - bi , j ] , L [ bi , j - 1 ] ) ; } } return L [ bi , n ] ; } public static void Main ( ) { string X = " AGGTAB " ; string Y = " GXTXAYB " ; Console . Write ( " Length ▁ of ▁ LCS ▁ is ▁ " + lcs ( X , Y ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int subsetXOR ( int [ ] arr , int n , int k ) { int max_ele = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) if ( arr [ i ] > max_ele ) max_ele = arr [ i ] ; int m = ( 1 << ( int ) ( Math . Log ( max_ele , 2 ) + 1 ) ) - 1 ; if ( k > m ) { return 0 ; } int [ , ] dp = new int [ n + 1 , m + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) for ( int j = 0 ; j <= m ; j ++ ) dp [ i , j ] = 0 ; dp [ 0 , 0 ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) for ( int j = 0 ; j <= m ; j ++ ) dp [ i , j ] = dp [ i - 1 , j ] + dp [ i - 1 , j ^ arr [ i - 1 ] ] ; return dp [ n , k ] ; } static public void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; int k = 4 ; int n = arr . Length ; Console . WriteLine ( " Count ▁ of ▁ subsets ▁ is ▁ " + subsetXOR ( arr , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMin ( int [ ] arr , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; bool [ , ] dp = new bool [ n + 1 , sum + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) dp [ i , 0 ] = true ; for ( int i = 1 ; i <= sum ; i ++ ) dp [ 0 , i ] = false ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= sum ; j ++ ) { dp [ i , j ] = dp [ i - 1 , j ] ; if ( arr [ i - 1 ] <= j ) dp [ i , j ] |= dp [ i - 1 , j - arr [ i - 1 ] ] ; } } int diff = int . MaxValue ; for ( int j = sum / 2 ; j >= 0 ; j -- ) { if ( dp [ n , j ] == true ) { diff = sum - 2 * j ; break ; } } return diff ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 1 , 4 , 2 , 2 , 1 } ; int n = arr . Length ; Console . WriteLine ( " The ▁ minimum ▁ difference ▁ " + " between ▁ 2 ▁ sets ▁ is ▁ " + findMin ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 100 ; static int [ , , , ] dp = new int [ MAX , MAX , MAX , 2 ] ; static int countPathsUtil ( int i , int j , int k , int d ) { if ( i < 0 j < 0 ) return 0 ; if ( i == 0 && j == 0 ) return 1 ; if ( k == 0 ) { if ( d == 0 && i == 0 ) return 1 ; if ( d == 1 && j == 0 ) return 1 ; return 0 ; } if ( dp [ i , j , k , d ] != - 1 ) return dp [ i , j , k , d ] ; if ( d == 0 ) return dp [ i , j , k , d ] = countPathsUtil ( i , j - 1 , k , d ) + countPathsUtil ( i - 1 , j , k - 1 , d == 1 ? 0 : 1 ) ; return dp [ i , j , k , d ] = countPathsUtil ( i - 1 , j , k , d ) + countPathsUtil ( i , j - 1 , k - 1 , d == 1 ? 0 : 1 ) ; } static int countPaths ( int i , int j , int k ) { if ( i == 0 && j == 0 ) return 1 ; for ( int p = 0 ; p < MAX ; p ++ ) { for ( int q = 0 ; q < MAX ; q ++ ) { for ( int r = 0 ; r < MAX ; r ++ ) for ( int s = 0 ; s < 2 ; s ++ ) dp [ p , q , r , s ] = - 1 ; } } } public static void Main ( String [ ] args ) { int m = 3 , n = 3 , k = 2 ; Console . WriteLine ( " Number ▁ of ▁ paths ▁ is ▁ " + countPaths ( m - 1 , n - 1 , k ) ) ; } }

Accumulator variables: p, q, r, s
Iterator variables: p, q, r, s
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 1000 ; static int [ , ] dp = new int [ MAX , MAX ] ; static int minSizeRec ( int [ ] arr , int low , int high , int k ) { if ( dp [ low , high ] != - 1 ) { return dp [ low , high ] ; } if ( ( high - low + 1 ) < 3 ) { return high - low + 1 ; } int res = 1 + minSizeRec ( arr , low + 1 , high , k ) ; for ( int i = low + 1 ; i <= high - 1 ; i ++ ) { for ( int j = i + 1 ; j <= high ; j ++ ) { if ( arr [ i ] == ( arr [ low ] + k ) && arr [ j ] == ( arr [ low ] + 2 * k ) && minSizeRec ( arr , low + 1 , i - 1 , k ) == 0 && minSizeRec ( arr , i + 1 , j - 1 , k ) == 0 ) { res = Math . Min ( res , minSizeRec ( arr , j + 1 , high , k ) ) ; } } } return ( dp [ low , high ] = res ) ; } static int minSize ( int [ ] arr , int n , int k ) { for ( int i = 0 ; i < MAX ; i ++ ) { for ( int j = 0 ; j < MAX ; j ++ ) { dp [ i , j ] = - 1 ; } } return minSizeRec ( arr , 0 , n - 1 , k ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 4 , 5 , 6 , 4 } ; int n = arr . Length ; int k = 1 ; Console . WriteLine ( minSize ( arr , n , k ) ) ; } }

Index/key variables: i, j, low
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int countSol ( int [ ] coeff , int start , int end , int rhs ) { if ( rhs == 0 ) return 1 ; int result = 0 ; for ( int i = start ; i <= end ; i ++ ) if ( coeff [ i ] <= rhs ) result += countSol ( coeff , i , end , rhs - coeff [ i ] ) ; return result ; } public static void Main ( ) { int [ ] coeff = { 2 , 2 , 5 } ; int rhs = 4 ; int n = coeff . Length ; Console . Write ( countSol ( coeff , 0 , n - 1 , rhs ) ) ; } }

Index/key variables: i
Accumulator variables: i, result
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int getMaxRec ( string str , int i , int n , int [ ] lookup ) { if ( i >= n ) return 0 ; if ( lookup [ i ] != - 1 ) return lookup [ i ] ; int ans = 1 + getMaxRec ( str , i + 1 , n , lookup ) ; if ( i + 1 < n ) { if ( str [ i ] != str [ i + 1 ] ) ans = Math . Max ( 4 + getMaxRec ( str , i + 2 , n , lookup ) , ans ) ; else ans = Math . Max ( 3 + getMaxRec ( str , i + 2 , n , lookup ) , ans ) ; } return lookup [ i ] = ans ; } static int getMaxWeight ( string str ) { int n = str . Length ; int [ ] lookup = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) lookup [ i ] = - 1 ; return getMaxRec ( str , 0 , str . Length , lookup ) ; } public static void Main ( ) { string str = " AAAAABB " ; Console . Write ( " Maximum ▁ weight ▁ of ▁ a " + " ▁ transformation ▁ of ▁ " + str + " ▁ is ▁ " + getMaxWeight ( str ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int steps ( int source , int step , int dest ) { if ( Math . Abs ( source ) > ( dest ) ) return int . MaxValue ; if ( source == dest ) return step ; int pos = steps ( source + step + 1 , step + 1 , dest ) ; int neg = steps ( source - step - 1 , step + 1 , dest ) ; return Math . Min ( pos , neg ) ; } public static void Main ( ) { int dest = 11 ; Console . WriteLine ( " No . ▁ of ▁ steps ▁ required " + " ▁ to ▁ reach ▁ " + dest + " ▁ is ▁ " + steps ( 0 , 0 , dest ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void possibleEqualArray ( int [ ] A , int N ) { int tot_XOR = 0 ; for ( int i = 0 ; i < N ; i ++ ) { tot_XOR ^= A [ i ] ; } if ( tot_XOR == 0 ) { Console . Write ( " YES " ) ; return ; } int cur_XOR = 0 ; int cnt = 0 ; for ( int i = 0 ; i < N ; i ++ ) { cur_XOR ^= A [ i ] ; if ( cur_XOR == tot_XOR ) { cnt ++ ; cur_XOR = 0 ; } } if ( cnt > 2 ) { Console . Write ( " YES " ) ; } else { Console . Write ( " NO " ) ; } } public static void Main ( String [ ] args ) { int [ ] A = { 0 , 2 , 2 } ; int N = ( A . Length ) ; possibleEqualArray ( A , N ) ; } }

Index/key variables: i
Accumulator variables: cnt, cur_XOR, i, tot_XOR
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int countPalindromes ( String S ) { int N = ( int ) S . Length ; int [ ] Z = new int [ ( N ) ] ; int l = 0 , r = 0 ; for ( int i = 1 ; i < N ; i ++ ) { if ( i <= r ) Z [ i ] = Math . Min ( r - i + 1 , Z [ i - l ] ) ; while ( i + Z [ i ] < N && S [ Z [ i ] ] == S [ i + Z [ i ] ] ) { Z [ i ] ++ ; } if ( i + Z [ i ] - 1 > r ) { l = i ; r = i + Z [ i ] - 1 ; } } int sum = 0 ; for ( int i = 0 ; i < Z . Length ; i ++ ) { sum += Z [ i ] + 1 ; } return sum ; } public static void Main ( String [ ] args ) { String S = " abab " ; Console . WriteLine ( countPalindromes ( S ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static void printSubsInDelimeters ( string str ) { Stack dels = new Stack ( ) ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( str [ i ] == ' [ ' ) { dels . Push ( i ) ; } else if ( str [ i ] == ' ] ' && dels . Count > 0 ) { int pos = ( int ) dels . Peek ( ) ; dels . Pop ( ) ; int len = i - 1 - pos ; string ans = str . Substring ( pos + 1 , len ) ; Console . WriteLine ( ans ) ; } } } static void Main ( ) { string str = " [ This ▁ is ▁ first ] ▁ ignored ▁ text ▁ [ This ▁ is ▁ second ] " ; printSubsInDelimeters ( str ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void printDiagonalTraversal ( int [ , ] nums ) { int m = nums . GetLength ( 0 ) ; Queue < pair > q = new Queue < pair > ( ) ; q . Enqueue ( new pair ( 0 , 0 ) ) ; while ( q . Count != 0 ) { pair p = q . Peek ( ) ; q . Dequeue ( ) ; Console . Write ( nums [ p . first , p . second ] + " ▁ " ) ; if ( p . second == 0 && p . first + 1 < m ) { q . Enqueue ( new pair ( p . first + 1 , p . second ) ) ; } if ( p . second + 1 < nums . GetLength ( 1 ) ) q . Enqueue ( new pair ( p . first , p . second + 1 ) ) ; } } public static void Main ( String [ ] args ) { int [ , ] arr = { { 1 , 2 , 3 } , { 4 , 5 , 6 } , { 7 , 8 , 9 } } ; printDiagonalTraversal ( arr ) ; } }

Class/struct names: GFG, pair
C# program:
using System ; using System . Collections . Generic ; class GFG { static List < int > restore ( int [ ] arr , int N ) { List < int > result = new List < int > ( ) ; Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( mp . ContainsKey ( arr [ i ] ) && mp [ arr [ i ] ] == 0 ) { result . Add ( arr [ i ] ) ; if ( mp . ContainsKey ( arr [ i ] ) ) { mp [ arr [ i ] ] = mp [ arr [ i ] ] + 1 ; } else { mp . Add ( arr [ i ] , 1 ) ; } } else mp . Add ( arr [ i ] , 0 ) ; } return result ; } static void print_result ( List < int > result ) { for ( int i = 0 ; i < result . Count ; i ++ ) Console . Write ( result [ i ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 13 , 1 , 24 , 13 , 24 , 2 , 2 } ; int N = arr . Length ; print_result ( restore ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static List < int > restore ( int [ ] arr , int N ) { List < int > result = new List < int > ( ) ; int count1 = 1 ; HashSet < int > s = new HashSet < int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { s . Add ( arr [ i ] ) ; if ( s . Count == count1 ) { result . Add ( arr [ i ] ) ; count1 ++ ; } } return result ; } static void print_result ( List < int > result ) { for ( int i = 0 ; i < result . Count ; i ++ ) Console . Write ( result [ i ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 13 , 1 , 24 , 13 , 24 , 2 , 2 } ; int N = arr . Length ; print_result ( restore ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: count1, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int sum ( int n ) { return n * ( n - 1 ) / 2 ; } static void BSpattern ( int N ) { int Val = 0 , Pthree = 0 , cnt = 0 , initial = - 1 ; String s = " * * " ; for ( int i = 0 ; i < N ; i ++ ) { cnt = 0 ; if ( i > 0 ) { Console . Write ( s ) ; s += " * * " ; } for ( int j = i ; j < N ; j ++ ) { if ( i > 0 ) { cnt ++ ; } Console . Write ( ++ Val ) ; Console . Write ( "0" ) ; } if ( i == 0 ) { int Sumbeforelast = sum ( Val ) * 2 ; Pthree = Val + Sumbeforelast + 1 ; initial = Pthree ; } initial = initial - cnt ; Pthree = initial ; for ( int k = i ; k < N ; k ++ ) { Console . Write ( Pthree ++ ) ; if ( k != N - 1 ) { Console . Write ( "0" ) ; } } Console . WriteLine ( ) ; } } public static void Main ( String [ ] args ) { int N = 5 ; BSpattern ( N ) ; } }

Accumulator variables: Pthree, cnt, i, j, k, s
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static bool checkprefix ( int A , int B ) { String s1 = A . ToString ( ) ; String s2 = B . ToString ( ) ; int n1 = s1 . Length ; int n2 = s2 . Length ; if ( n1 < n2 ) { return false ; } for ( int i = 0 ; i < n2 ; i ++ ) { if ( s1 [ i ] != s2 [ i ] ) { return false ; } } return true ; } static public void Main ( ) { int A = 12345 , B = 12 ; bool result = checkprefix ( A , B ) ; if ( result ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void possibleToReach ( int x , int y , int z ) { if ( z < Math . Abs ( x ) + Math . Abs ( y ) || ( z - Math . Abs ( x ) - Math . Abs ( y ) ) % 2 == 1 ) { Console . Write ( " Not ▁ Possible " + " STRNEWLINE " ) ; } else Console . Write ( " Possible " + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int x = 5 , y = 5 ; int z = 11 ; possibleToReach ( x , y , z ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int nCycle ( int N ) { return ( N ) * ( N - 1 ) + 1 ; } public static void Main ( String [ ] args ) { int N = 4 ; Console . Write ( nCycle ( N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] a = new int [ 65 ] ; static int Count ( int i ) { if ( i == 0 ) return 1 ; else if ( i < 0 ) return 0 ; if ( a [ i ] == 0 ) { a [ i ] = ( i + 1 ) + 2 * Count ( i - 1 ) ; return a [ i ] ; } else return a [ i ] ; } static int solve ( int n ) { int i , sum = 0 ; while ( n > 0 ) { i = ( int ) ( Math . Log ( n ) / Math . Log ( 2 ) ) ; n = n - ( int ) Math . Pow ( 2 , i ) ; sum = sum + ( i + 1 ) + Count ( i - 1 ) ; } return sum ; } public static void Main ( String [ ] args ) { int n = 7 ; Console . Write ( solve ( n ) ) ; } }

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