dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static int minCut ( string a ) { int [ ] cut = new int [ a . Length ] ; bool [ , ] palindrome = new bool [ a . Length , a . Length ] ; for ( int i = 0 ; i < a . Length ; i ++ ) { int minCut = i ; for ( int j = 0 ; j <= i ; j ++ ) { if ( a [ i ] == a [ j ] && ( i - j < 2 palindrome [ j + 1 , i - 1 ] ) ) { palindrome [ j , i ] = true ; minCut = Math . Min ( minCut , j == 0 ? 0 : ( cut [ j - 1 ] + 1 ) ) ; } } cut [ i ] = minCut ; } return cut [ a . Length - 1 ] ; } static void Main ( ) { Console . WriteLine ( minCut ( " aab " ) ) ; Console . WriteLine ( minCut ( " aabababaxx " ) ) ; } }

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

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: LBS
C# program:
using System ; class GFG { static int max ( int a , int b ) { return ( a > b ) ? a : b ; } static int eggDrop ( int n , int k ) { int [ , ] eggFloor = new int [ n + 1 , k + 1 ] ; int res ; int i , j , x ; for ( i = 1 ; i <= n ; i ++ ) { eggFloor [ i , 1 ] = 1 ; eggFloor [ i , 0 ] = 0 ; } for ( j = 1 ; j <= k ; j ++ ) eggFloor [ 1 , j ] = j ; for ( i = 2 ; i <= n ; i ++ ) { for ( j = 2 ; j <= k ; j ++ ) { eggFloor [ i , j ] = int . MaxValue ; for ( x = 1 ; x <= j ; x ++ ) { res = 1 + max ( eggFloor [ i - 1 , x - 1 ] , eggFloor [ i , j - x ] ) ; if ( res < eggFloor [ i , j ] ) eggFloor [ i , j ] = res ; } } } return eggFloor [ n , k ] ; } public static void Main ( ) { int n = 2 , k = 36 ; Console . WriteLine ( " Minimum ▁ number ▁ of ▁ trials ▁ " + " in ▁ worst ▁ case ▁ with ▁ " + n + " ▁ eggs ▁ and ▁ " + k + " floors ▁ is ▁ " + eggDrop ( n , k ) ) ; } }

Accumulator variables: i, j, x
Iterator variables: i, j, x
Class/struct names: GFG
C# program:
using System ; class GFG { static int max ( int a , int b ) { return ( a > b ) ? a : b ; } static int knapSack ( int W , int [ ] wt , int [ ] val , int n ) { if ( n == 0 W == 0 ) return 0 ; if ( wt [ n - 1 ] > W ) return knapSack ( W , wt , val , n - 1 ) ; else return max ( val [ n - 1 ] + knapSack ( W - wt [ n - 1 ] , wt , val , n - 1 ) , knapSack ( W , wt , val , n - 1 ) ) ; } public static void Main ( ) { int [ ] val = new int [ ] { 60 , 100 , 120 } ; int [ ] wt = new int [ ] { 10 , 20 , 30 } ; int W = 50 ; int n = val . Length ; Console . WriteLine ( knapSack ( W , wt , val , n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int row = 3 ; static int col = 3 ; static int minCost ( int [ , ] cost ) { for ( int i = 1 ; i < row ; i ++ ) { cost [ i , 0 ] += cost [ i - 1 , 0 ] ; } for ( int j = 1 ; j < col ; j ++ ) { cost [ 0 , j ] += cost [ 0 , j - 1 ] ; } for ( int i = 1 ; i < row ; i ++ ) { for ( int j = 1 ; j < col ; j ++ ) { cost [ i , j ] += Math . Min ( cost [ i - 1 , j - 1 ] , Math . Min ( cost [ i - 1 , j ] , cost [ i , j - 1 ] ) ) ; } } return cost [ row - 1 , col - 1 ] ; } public static void Main ( String [ ] args ) { int [ , ] cost = { { 1 , 2 , 3 } , { 4 , 8 , 2 } , { 1 , 5 , 3 } } ; Console . Write ( minCost ( cost ) + " STRNEWLINE " ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class LIS { static int max_ref ; static int _lis ( int [ ] arr , int n ) { if ( n == 1 ) return 1 ; int res , max_ending_here = 1 ; for ( int i = 1 ; i < n ; i ++ ) { res = _lis ( arr , i ) ; if ( arr [ i - 1 ] < arr [ n - 1 ] && res + 1 > max_ending_here ) max_ending_here = res + 1 ; } if ( max_ref < max_ending_here ) max_ref = max_ending_here ; return max_ending_here ; } static int lis ( int [ ] arr , int n ) { max_ref = 1 ; _lis ( arr , n ) ; return max_ref ; } public static void Main ( ) { int [ ] arr = { 10 , 22 , 9 , 33 , 21 , 50 , 41 , 60 } ; int n = arr . Length ; Console . Write ( " Length ▁ of ▁ lis ▁ is ▁ " + lis ( arr , n ) + " STRNEWLINE " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: LIS
C# program:
using System ; class GFG { static int factorial ( int n ) { int res = 1 ; for ( int i = 1 ; i <= n ; ++ i ) { res *= i ; } return res ; } static int binomialCoeff ( int n , int k ) { int res = 1 ; if ( k > n - k ) k = n - k ; for ( int i = 0 ; i < k ; ++ i ) { res *= ( n - i ) ; res /= ( i + 1 ) ; } return res ; } static int catalan ( int n ) { int c = binomialCoeff ( 2 * n , n ) ; return c / ( n + 1 ) ; } static int countBST ( int n ) { int count = catalan ( n ) ; return count ; } static int countBT ( int n ) { int count = catalan ( n ) ; return count * factorial ( n ) ; } static public void Main ( ) { int count1 , count2 , n = 5 ; count1 = countBST ( n ) ; count2 = countBT ( n ) ; Console . WriteLine ( " Count ▁ of ▁ BST ▁ with ▁ " + n + " ▁ nodes ▁ is ▁ " + count1 ) ; Console . WriteLine ( " Count ▁ of ▁ binary ▁ " + " trees ▁ with ▁ " + n + " ▁ nodes ▁ is ▁ " + count2 ) ; } }

Accumulator variables: res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void getMissingNumbers ( int [ ] arr , int N ) { for ( int i = 0 ; i < N ; i ++ ) { arr [ Math . Abs ( arr [ i ] ) - 1 ] = - ( Math . Abs ( arr [ Math . Abs ( arr [ i ] ) - 1 ] ) ) ; } for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] > 0 ) Console . Write ( i + 1 + " ▁ " ) ; } } public static void Main ( ) { int N = 5 ; int [ ] arr = { 5 , 5 , 4 , 4 , 2 } ; getMissingNumbers ( 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 { public static bool PosCheck ( char [ , ] a , int n , int m , char check ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( a [ i , j ] == ' * ' ) { continue ; } else { if ( ( ( ( i + j ) & 1 ) == 1 ) && a [ i , j ] != check ) { return false ; } if ( ! ( ( ( i + j ) & 1 ) == 1 ) && a [ i , j ] == check ) { return false ; } } } } return true ; } public static void fill ( char [ , ] a , int n , int m , char odd , char even ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( ( ( i + j ) & 1 ) == 1 ) { a [ i , j ] = odd ; } else { a [ i , j ] = even ; } } } } public static void findPossibleGrid ( int n , int m , char [ , ] a ) { bool flag = true ; int k = - 1 , o = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( a [ i , j ] != ' * ' ) { k = i ; o = j ; break ; } } if ( k != - 1 ) { break ; } } if ( k != - 1 ) { flag = PosCheck ( a , n , m , '1' ) ; if ( flag ) { fill ( a , n , m , '1' , '0' ) ; } else { flag = PosCheck ( a , n , m , '0' ) ; if ( flag ) { fill ( a , n , m , '0' , '1' ) ; } } } else { char h = '1' ; for ( int i = 0 ; i < m ; i ++ ) { a [ 0 , i ] = h ; if ( h == '1' ) { h = '0' ; } else { h = '1' ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( i - 1 < 0 ) { continue ; } if ( a [ i - 1 , j ] == '1' ) { a [ i , j ] = '0' ; } else { a [ i , j ] = '1' ; } } } flag = true ; } if ( ! flag ) { Console . WriteLine ( " No " ) ; } else { Console . WriteLine ( " Yes " ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { Console . Write ( a [ i , j ] ) ; } Console . WriteLine ( ) ; } } } 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: flag
Class/struct names: GFG
C# program:
using System ; class GFG { static int oddLengthPalindrome ( int k ) { int palin = k ; k = k / 10 ; while ( k > 0 ) { int rev = k % 10 ; palin = ( palin * 10 ) + rev ; k = k / 10 ; } return palin ; } static void Main ( string [ ] args ) { int k = 504 ; Console . WriteLine ( oddLengthPalindrome ( k ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void maxSubsequenceLen ( string s , int K ) { int N = s . Length ; int start = 0 , end = 0 ; char [ ] S = s . ToCharArray ( ) ; Array . Sort ( S ) ; int ans = Int32 . MinValue , sum = 0 ; for ( end = 0 ; end < N ; end ++ ) { sum = sum + ( S [ end ] - ' a ' ) ; while ( sum + K < ( S [ end ] - ' a ' ) * ( end - start + 1 ) ) { sum = sum - ( S [ start ] - ' a ' ) ; start ++ ; } ans = Math . Max ( ans , end - start + 1 ) ; } Console . WriteLine ( ans ) ; } public static void Main ( ) { string S = " acscbcca " ; int K = 1 ; maxSubsequenceLen ( S , K ) ; } }

Index/key variables: end, start
Accumulator variables: end, start
Iterator variables: end
Class/struct names: GFG
C# program:
using System ; class GFG { static string checkPro ( int n , int k ) { double exp = 1.0 / k ; int KthRoot = ( int ) Math . Pow ( n , exp ) ; int product = 1 ; for ( int i = 1 ; i < k + 1 ; i ++ ) { product = product * i ; } if ( product == n ) return " Yes " ; else { for ( int j = 2 ; j < KthRoot + 1 ; j ++ ) { product = product * ( j + k - 1 ) ; product = product / ( j - 1 ) ; if ( product == n ) return " Yes " ; } } return " No " ; } static public void Main ( ) { int N = 210 ; int K = 3 ; Console . WriteLine ( checkPro ( N , K ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void minOperations ( string s1 , string s2 , int n ) { char [ ] a = s1 . ToCharArray ( ) ; char [ ] b = s2 . ToCharArray ( ) ; List < int > ops = new List < int > ( ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( a [ i ] != b [ i ] ) { if ( a [ 0 ] == b [ i ] ) { ops . Add ( 1 ) ; a [ 0 ] = ( a [ 0 ] == '0' ? '1' : '0' ) ; } reverse ( a , 0 , i ) ; for ( int j = 0 ; j <= i ; j ++ ) { a [ j ] = ( a [ j ] == '0' ? '1' : '0' ) ; } ops . Add ( i + 1 ) ; } } Console . WriteLine ( ops . Count ) ; foreach ( int x in ops ) { Console . Write ( x + " ▁ " ) ; } } static void reverse ( char [ ] a , int start , int end ) { while ( start < end ) { char temp = a [ start ] ; a [ start ] = a [ end ] ; a [ end ] = temp ; start ++ ; end -- ; } } public static void Main ( ) { string a = "10" , b = "01" ; int N = a . Length ; minOperations ( a , b , N ) ; } }

Index/key variables: end, i, j, start
Accumulator variables: end, i, j, start
Iterator variables: i, j, x
Class/struct names: GFG
C# program:
using System ; class GFG { static int findCount0th ( int [ ] arr , int N , int K ) { int oddsum = 0 , evensum = 0 ; for ( int i = 1 ; i < N ; i += 2 ) { oddsum += arr [ i ] ; } for ( int i = 2 ; i < N ; i += 2 ) { evensum += arr [ i ] ; } if ( Math . Abs ( oddsum - evensum ) == K ) return 1 ; else return 0 ; } static int findCount1st ( int [ ] arr , int N , int K ) { int evensum = arr [ 0 ] , oddsum = 0 ; for ( int i = 3 ; i < N ; i += 2 ) { evensum += arr [ i ] ; } for ( int i = 2 ; i < N ; i += 2 ) { oddsum += arr [ i ] ; } if ( Math . Abs ( oddsum - evensum ) == K ) return 1 ; else return 0 ; } static int countTimes ( int [ ] arr , int K ) { int N = ( int ) arr . Length ; if ( N == 1 ) return 1 ; if ( N < 3 ) return 0 ; if ( N == 3 ) { int cnt = 0 ; cnt += ( Math . Abs ( arr [ 0 ] - arr [ 1 ] ) == K ? 1 : 0 ) + ( Math . Abs ( arr [ 2 ] - arr [ 1 ] ) == K ? 1 : 0 ) + ( Math . Abs ( arr [ 0 ] - arr [ 2 ] ) == K ? 1 : 0 ) ; return cnt ; } int [ ] prefix = new int [ N + 2 ] ; int [ ] suffix = new int [ N + 2 ] ; for ( int i = 0 ; i < N + 2 ; i ++ ) { prefix [ i ] = 0 ; } for ( int i = 0 ; i < N + 2 ; i ++ ) { suffix [ i ] = 0 ; } prefix [ 0 ] = arr [ 0 ] ; prefix [ 1 ] = arr [ 1 ] ; suffix [ N - 1 ] = arr [ N - 1 ] ; suffix [ N - 2 ] = arr [ N - 2 ] ; for ( int i = 2 ; i < N ; i += 2 ) { prefix [ i ] = arr [ i ] + prefix [ i - 2 ] ; } for ( int i = 3 ; i < N ; i += 2 ) { prefix [ i ] = arr [ i ] + prefix [ i - 2 ] ; } for ( int i = N - 3 ; i >= 0 ; i -= 2 ) { suffix [ i ] = arr [ i ] + suffix [ i + 2 ] ; } for ( int i = N - 4 ; i >= 0 ; i -= 2 ) { suffix [ i ] = arr [ i ] + suffix [ i + 2 ] ; } int count = 0 ; for ( int i = 2 ; i < N ; i ++ ) { if ( Math . Abs ( prefix [ i - 1 ] + suffix [ i + 2 ] - prefix [ i - 2 ] - suffix [ i + 1 ] ) == K ) { count ++ ; } } count += findCount0th ( arr , N , K ) ; count += findCount1st ( arr , N , K ) ; return count ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 4 , 5 , 6 } ; int K = 2 ; Console . WriteLine ( countTimes ( arr , K ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, count, evensum, i, oddsum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int N , M ; static int [ , ] mat ; static int row , col , start , flag ; static void fillMatrix ( int sizeOfpart , int noOfPart , int m ) { for ( int i = 0 ; i < noOfPart ; ++ i ) { int count = 0 ; while ( count < sizeOfpart ) { mat [ row , col ] = start ; if ( col == m - 1 && flag == 1 ) { row ++ ; col = m ; flag = 0 ; } else if ( col == 0 && flag == 0 ) { row ++ ; col = - 1 ; flag = 1 ; } if ( flag == 1 ) { col ++ ; } else { col -- ; } count ++ ; } start ++ ; } } static void findMatrix ( int k ) { mat = new int [ M , N ] ; row = 0 ; col = 0 ; int size = ( N * M ) / k ; int rem = ( N * M ) % k ; start = 1 ; flag = 1 ; fillMatrix ( size + 1 , rem , M ) ; fillMatrix ( size , k - rem , M ) ; } static void printMatrix ( ) { for ( int i = 0 ; i < N ; ++ i ) { for ( int j = 0 ; j < M ; ++ j ) { Console . Write ( mat [ i , j ] + " ▁ " ) ; } Console . WriteLine ( ) ; } } public static void Main ( String [ ] args ) { N = 5 ; M = 5 ; int K = 6 ; findMatrix ( K ) ; printMatrix ( ) ; } }

Accumulator variables: col, count, row, start
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static string changeString ( string S ) { char [ ] s = S . ToCharArray ( ) ; int N = S . Length ; if ( s [ 0 ] == ' ? ' ) { s [ 0 ] = ' a ' ; if ( s [ 0 ] == s [ 1 ] ) { s [ 0 ] ++ ; } } for ( int i = 1 ; i < N - 1 ; i ++ ) { if ( s [ i ] == ' ? ' ) { s [ i ] = ' a ' ; if ( s [ i ] == s [ i - 1 ] ) { s [ i ] ++ ; } if ( s [ i ] == s [ i + 1 ] ) { s [ i ] ++ ; } if ( s [ i ] == s [ i - 1 ] ) { s [ i ] ++ ; } } } if ( s [ N - 1 ] == ' ? ' ) { s [ N - 1 ] = ' a ' ; if ( s [ N - 1 ] == s [ N - 2 ] ) { s [ N - 1 ] ++ ; } } string ans = " " ; for ( int i = 0 ; i < s . Length ; i ++ ) { ans += s [ i ] ; } return ans ; } public static void Main ( ) { string S = " ? a ? a " ; Console . WriteLine ( changeString ( S ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int checkReverseBitonic ( String s ) { int i , j ; for ( i = 1 ; i < s . Length ; i ++ ) { if ( s [ i ] < s [ i - 1 ] ) continue ; if ( s [ i ] >= s [ i - 1 ] ) break ; } if ( i == s . Length - 1 ) return 1 ; for ( j = i + 1 ; j < s . Length ; j ++ ) { if ( s [ j ] > s [ j - 1 ] ) continue ; if ( s [ j ] <= s [ j - 1 ] ) break ; } i = j ; if ( i != s . Length ) return 0 ; return 1 ; } public static void Main ( String [ ] args ) { String s = " abcdwef " ; if ( checkReverseBitonic ( s ) == 1 ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } }

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 smallestNum ( int N ) { float x = ( float ) ( Math . Pow ( 10 , ( N - 1 ) / 2.0 ) ) ; return ( int ) ( Math . Ceiling ( x ) ) ; } public static void Main ( ) { int N = 4 ; Console . Write ( smallestNum ( N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public static int countKCountdown ( int [ ] arr , int N , int K ) { int flag = - 1 ; int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == K ) flag = K ; if ( arr [ i ] == flag ) flag -- ; else flag = - 1 ; if ( flag == 0 ) count ++ ; } return count ; } public static void Main ( ) { int N = 8 ; int K = 3 ; int [ ] arr = { 4 , 3 , 2 , 1 , 5 , 3 , 2 , 1 } ; Console . Write ( countKCountdown ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: count, flag, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static string decToHexa ( int n ) { char [ ] hexaDeciNum = new char [ 2 ] ; int i = 0 ; while ( n != 0 ) { int temp = 0 ; temp = n % 16 ; if ( temp < 10 ) { hexaDeciNum [ i ] = ( char ) ( temp + 48 ) ; i ++ ; } else { hexaDeciNum [ i ] = ( char ) ( temp + 55 ) ; i ++ ; } n = n / 16 ; } string hexCode = " " ; if ( i == 2 ) { hexCode += hexaDeciNum [ 0 ] ; hexCode += hexaDeciNum [ 1 ] ; } else if ( i == 1 ) { hexCode = "0" ; hexCode += hexaDeciNum [ 0 ] ; } else if ( i == 0 ) hexCode = "00" ; return hexCode ; } static string convertRGBtoHex ( int R , int G , int B ) { if ( ( R >= 0 && R <= 255 ) && ( G >= 0 && G <= 255 ) && ( B >= 0 && B <= 255 ) ) { string hexCode = " # " ; hexCode += decToHexa ( R ) ; hexCode += decToHexa ( G ) ; hexCode += decToHexa ( B ) ; return hexCode ; } else return " - 1" ; } public static void Main ( string [ ] args ) { int R = 0 , G = 0 , B = 0 ; Console . Write ( convertRGBtoHex ( R , G , B ) + " STRNEWLINE " ) ; R = 255 ; G = 255 ; B = 255 ; Console . Write ( convertRGBtoHex ( R , G , B ) + " STRNEWLINE " ) ; R = 25 ; G = 56 ; B = 123 ; Console . Write ( convertRGBtoHex ( R , G , B ) + " STRNEWLINE " ) ; R = 2 ; G = 3 ; B = 4 ; Console . Write ( convertRGBtoHex ( R , G , B ) + " STRNEWLINE " ) ; R = 255 ; G = 255 ; B = 256 ; Console . Write ( convertRGBtoHex ( R , G , B ) + " STRNEWLINE " ) ; } }

Index/key variables: i
Accumulator variables: hexCode, i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void getStrings ( String str , String [ ] arr ) { for ( int i = 0 ; i < arr . Length ; i ++ ) { if ( check ( arr [ i ] , str ) ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } } public static bool check ( String s , String str ) { char [ ] chars = s . ToCharArray ( ) ; foreach ( char c in chars ) { if ( ! str . Contains ( String . Join ( " " , c ) ) ) { return false ; } } for ( int i = 0 ; i < chars . Length - 1 ; i ++ ) { if ( chars [ i ] == chars [ i + 1 ] ) { return false ; } } return true ; } public static void Main ( String [ ] args ) { String str = " ABCD " ; String [ ] arr = { " AABCDA " , " ABCDZADC " , " ABCDBCA " , " ABCDABDCA " } ; getStrings ( str , arr ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: c, i
Class/struct names: GFG
C# program:
using System ; class GFG { static void q1 ( string s , int i ) { if ( i == s . Length ) { Console . WriteLine ( " Yes " ) ; return ; } if ( s [ i ] == ' a ' ) q1 ( s , i + 1 ) ; else q2 ( s , i + 1 ) ; } static void q2 ( string s , int i ) { if ( i == s . Length ) { Console . WriteLine ( " No " ) ; return ; } if ( s [ i ] == ' a ' ) q1 ( s , i + 1 ) ; else q2 ( s , i + 1 ) ; } static void q3 ( string s , int i ) { if ( i == s . Length ) { Console . WriteLine ( " Yes " ) ; return ; } if ( s [ i ] == ' a ' ) q4 ( s , i + 1 ) ; else q3 ( s , i + 1 ) ; } static void q4 ( string s , int i ) { if ( i == s . Length ) { Console . WriteLine ( " No " ) ; return ; } if ( s [ i ] == ' a ' ) q4 ( s , i + 1 ) ; else q3 ( s , i + 1 ) ; } static void q0 ( string s , int i ) { if ( i == s . Length ) { Console . WriteLine ( " No " ) ; return ; } if ( s [ i ] == ' a ' ) q1 ( s , i + 1 ) ; else q3 ( s , i + 1 ) ; } public static void Main ( ) { string s = " abbaabb " ; q0 ( s , 0 ) ; } }

Index/key variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void prefix ( char [ ] str ) { int k = 1 , j ; int n = str . Length ; List < int > g = new List < int > ( ) ; int flag = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( str [ i ] == str [ 0 ] ) { g . Add ( i ) ; flag = 1 ; } } if ( flag == 0 ) { Console . WriteLine ( String . Join ( " " , str ) ) ; } else { int len = g . Count ; while ( k < g [ 0 ] ) { int cnt = 0 ; for ( j = 0 ; j < len ; j ++ ) { if ( ( g [ j ] + k ) < n && str [ g [ j ] + k ] == str [ k ] ) { cnt ++ ; } } if ( cnt == len ) { k ++ ; } else { break ; } } for ( int i = 0 ; i < k ; i ++ ) { Console . Write ( str [ i ] ) ; } Console . WriteLine ( ) ; } } public static void Main ( ) { String str = " abcab " ; prefix ( str . ToCharArray ( ) ) ; } }

Index/key variables: i, j, k
Accumulator variables: cnt, i, j, k
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static void printPermutation ( int N , int K ) { ArrayList res = new ArrayList ( ) ; int l = 1 , r = N , flag = 0 ; for ( int i = 0 ; i < K ; i ++ ) { if ( flag == 0 ) { res . Add ( l ) ; l ++ ; } else { res . Add ( r ) ; r -- ; } flag ^= 1 ; } if ( flag != 1 ) { for ( int i = r ; i >= l ; i -- ) { res . Add ( i ) ; } } else { for ( int i = l ; i <= r ; i ++ ) { res . Add ( i ) ; } } foreach ( int i in res ) { Console . Write ( i + " ▁ " ) ; } } public static void Main ( ) { int N = 10 , K = 4 ; printPermutation ( N , K ) ; } }

Accumulator variables: flag, i, l, r
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int fact ( int N ) { int i , product = 1 ; for ( i = 1 ; i <= N ; i ++ ) product = product * i ; return product ; } public static int nthTerm ( int N ) { return ( N * N ) * fact ( N ) ; } public static void Main ( String [ ] args ) { Console . WriteLine ( nthTerm ( N ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { public readonly static int d = 256 ; static void search ( String pat , String txt , int q ) { int M = pat . Length ; int N = txt . Length ; int i , j ; int h = 1 ; for ( i = 0 ; i < M - 1 ; i ++ ) h = ( h * d ) % q ; for ( i = 0 ; i < M ; i ++ ) { p = ( d * p + pat [ i ] ) % q ; t = ( d * t + txt [ i ] ) % q ; } for ( i = 0 ; i <= N - M ; i ++ ) { if ( p == t ) { for ( j = 0 ; j < M ; j ++ ) { if ( txt [ i + j ] != pat [ j ] ) break ; } if ( j == M ) Console . WriteLine ( " Pattern ▁ found ▁ at ▁ index ▁ " + i ) ; } if ( i < N - M ) { t = ( d * ( t - txt [ i ] * h ) + txt [ i + M ] ) % q ; if ( t < 0 ) t = ( t + q ) ; } } } public static void Main ( ) { String txt = " GEEKS ▁ FOR ▁ GEEKS " ; String pat = " GEEK " ; int q = 101 ; search ( pat , txt , q ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Text ; class GFG { static void isOnesGreater ( string S , int N ) { StringBuilder st = new StringBuilder ( S ) ; int cnt0 = 0 ; int cnt1 = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( st [ i ] == '1' ) cnt1 ++ ; else cnt0 ++ ; } for ( int i = 0 ; i < N ; i ++ ) { if ( st [ i ] == '1' ) { if ( i > 0 && st [ i - 1 ] == '0' ) { st [ i - 1 ] = ' _ ' ; cnt0 -- ; } else if ( i < N && st [ i + 1 ] == '0' ) { st [ i + 1 ] = ' _ ' ; cnt0 -- ; } } } if ( cnt1 > cnt0 ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } public static void Main ( ) { string S = "01" ; int N = S . Length ; isOnesGreater ( S , N ) ; } }

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