dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static bool shouldSwap ( char [ ] str , int start , int curr ) { for ( int i = start ; i < curr ; i ++ ) { if ( str [ i ] == str [ curr ] ) { return false ; } } return true ; } static void findPermutations ( char [ ] str , int index , int n ) { if ( index >= n ) { Console . WriteLine ( str ) ; return ; } for ( int i = index ; i < n ; i ++ ) { bool check = shouldSwap ( str , index , i ) ; if ( check ) { swap ( str , index , i ) ; findPermutations ( str , index + 1 , n ) ; swap ( str , index , i ) ; } } } static void swap ( char [ ] str , int i , int j ) { char c = str [ i ] ; str [ i ] = str [ j ] ; str [ j ] = c ; } public static void Main ( ) { char [ ] str = { ' A ' , ' B ' , ' C ' , ' A ' } ; int n = str . Length ; findPermutations ( str , 0 , n ) ; } }

Index/key variables: curr, i, j
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static void findPermutations ( char [ ] str , int index , int n ) { if ( index >= n || ( index + 1 ) >= n ) { Console . WriteLine ( str ) ; return ; } findPermutations ( str , index + 1 , n ) ; swap ( str , index ) ; findPermutations ( str , index + 2 , n ) ; swap ( str , index ) ; } static void swap ( char [ ] arr , int index ) { char temp = arr [ index ] ; arr [ index ] = arr [ index + 1 ] ; arr [ index + 1 ] = temp ; } public static void Main ( ) { char [ ] str = "12345" . ToCharArray ( ) ; int n = str . Length ; findPermutations ( str , 0 , n ) ; } }

Index/key variables: index
Class/struct names: GFG
C# program:
using System ; class GFG { static string decodeMedianString ( string s ) { int l = s . Length ; string s1 = " " ; bool isEven = ( l % 2 == 0 ) ? true : false ; for ( int i = 0 ; i < l ; i += 2 ) { if ( isEven ) { s1 = s [ i ] + s1 ; s1 += s [ i + 1 ] ; } else { if ( l - i > 1 ) { s1 += s [ i ] ; s1 = s [ i + 1 ] + s1 ; } else { s1 += s [ i ] ; } } } return s1 ; } public static void Main ( ) { string s = " eekgs " ; Console . WriteLine ( decodeMedianString ( s ) ) ; } }

Index/key variables: i
Accumulator variables: i, s1
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int maximumChars ( string str ) { int n = str . Length ; int res = - 1 ; for ( int i = 0 ; i < n - 1 ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( str [ i ] == str [ j ] ) res = Math . Max ( res , Math . Abs ( j - i - 1 ) ) ; return res ; } static public void Main ( ) { string str = " abba " ; Console . WriteLine ( maximumChars ( str ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static int MAX_CHAR = 256 ; static int maximumChars ( string str ) { int n = str . Length ; int res = - 1 ; int [ ] firstInd = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) firstInd [ i ] = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { int first_ind = firstInd [ str [ i ] ] ; if ( first_ind == - 1 ) firstInd [ str [ i ] ] = i ; else res = Math . Max ( res , Math . Abs ( i - first_ind - 1 ) ) ; } return res ; } static public void Main ( ) { string str = " abba " ; Console . WriteLine ( maximumChars ( str ) ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isUnique ( int [ ] a , int n , int k ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += a [ i ] ; sum += n - 1 ; return ( sum == k ) ; } static public void Main ( ) { int [ ] a = { 3 , 3 , 3 } ; int n = a . Length ; int k = 12 ; if ( isUnique ( a , n , k ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static string nextWord ( string str ) { if ( str == " " ) { return " a " ; } int i = str . Length - 1 ; while ( str [ i ] == ' z ' && i >= 0 ) { i -- ; } if ( i == - 1 ) { str = str + ' a ' ; } else { str = str . Substring ( 0 , i ) + ( char ) ( ( int ) ( str [ i ] ) + 1 ) + str . Substring ( i + 1 ) ; } return str ; } public static void Main ( string [ ] args ) { string str = " samez " ; Console . Write ( nextWord ( str ) ) ; } }

Index/key variables: i
Accumulator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isValid ( string p ) { int n = p . Length ; int c1 = 0 , c0 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( p [ i ] == '0' ) { c0 ++ ; } if ( p [ i ] == '1' ) { c1 ++ ; } } if ( c0 == c1 ) { return true ; } else { return false ; } } public static int longestSub ( string s ) { int max_len = 0 ; int n = s . Length ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { if ( isValid ( s . Substring ( i , j - i + 1 ) ) && max_len < j - i + 1 ) { max_len = j - i + 1 ; } } } return max_len ; } static public void Main ( ) { string s = "101001000" ; Console . WriteLine ( longestSub ( s ) ) ; } }

Index/key variables: i
Accumulator variables: c0, c1, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX_CHAR = 26 ; public static void commonCharacters ( String [ ] str , int n ) { Boolean [ ] prim = new Boolean [ MAX_CHAR ] ; for ( int i = 0 ; i < prim . Length ; i ++ ) prim [ i ] = true ; for ( int i = 0 ; i < n ; i ++ ) { Boolean [ ] sec = new Boolean [ MAX_CHAR ] ; for ( int s = 0 ; s < sec . Length ; s ++ ) sec [ s ] = false ; for ( int j = 0 ; j < str [ i ] . Length ; j ++ ) { if ( prim [ str [ i ] [ j ] - ' a ' ] ) sec [ str [ i ] [ j ] - ' a ' ] = true ; } Array . Copy ( sec , 0 , prim , 0 , MAX_CHAR ) ; } for ( int i = 0 ; i < 26 ; i ++ ) if ( prim [ i ] ) { Console . Write ( ( char ) ( i + 97 ) ) ; Console . Write ( " ▁ " ) ; } } public static void Main ( String [ ] args ) { String [ ] str = { " geeksforgeeks " , " gemkstones " , " acknowledges " , " aguelikes " } ; int n = str . Length ; commonCharacters ( str , n ) ; } }

Index/key variables: MAX_CHAR, i, j, s
Accumulator variables: i, j, s
Iterator variables: i, j, s
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPalindrome ( String s , int i , int j ) { int p = j ; for ( int k = i ; k <= p ; k ++ ) { if ( s [ k ] != s [ p ] ) return false ; p -- ; } return true ; } static int countWays ( String s ) { int n = s . Length ; int count = 0 ; if ( isPalindrome ( s , 0 , n - 1 ) ) { for ( int i = n / 2 ; i < n ; i ++ ) { if ( s [ i ] == s [ i + 1 ] ) count ++ ; else break ; } if ( n % 2 == 0 ) { count ++ ; count = 2 * count + 1 ; } else count = 2 * count + 2 ; } else { for ( int i = 0 ; i < n / 2 ; i ++ ) { if ( s [ i ] != s [ n - 1 - i ] ) { int j = n - 1 - i ; if ( isPalindrome ( s , i , n - 2 - i ) ) { for ( int k = i - 1 ; k >= 0 ; k -- ) { if ( s [ k ] != s [ j ] ) break ; count ++ ; } count ++ ; } if ( isPalindrome ( s , i + 1 , n - 1 - i ) ) { for ( int k = n - i ; k < n ; k ++ ) { if ( s [ k ] != s [ i ] ) break ; count ++ ; } count ++ ; } break ; } } } return count ; } public static void Main ( ) { String s = " abca " ; Console . Write ( countWays ( s ) ) ; } }

Index/key variables: i, j, k, p
Accumulator variables: count, i, k, p
Iterator variables: i, k
Class/struct names: GFG
C# program:
using System ; public class GFG { static int countOfSubstringWithKOnes ( string s , int K ) { int N = s . Length ; int res = 0 ; int countOfOne = 0 ; int [ ] freq = new int [ N + 1 ] ; freq [ 0 ] = 1 ; for ( int i = 0 ; i < N ; i ++ ) { countOfOne += ( s [ i ] - '0' ) ; if ( countOfOne >= K ) { res += freq [ countOfOne - K ] ; } freq [ countOfOne ] ++ ; } return res ; } static public void Main ( ) { string s = "10010" ; int K = 1 ; Console . WriteLine ( countOfSubstringWithKOnes ( s , K ) ) ; } }

Index/key variables: countOfOne, i
Accumulator variables: countOfOne, i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX_CHAR = 256 ; static void printDuo ( string str ) { int [ ] countChar = new int [ MAX_CHAR ] ; int n = str . Length ; for ( int i = 0 ; i < n ; i ++ ) { countChar [ str [ i ] - ' a ' ] ++ ; } string str1 = " " , str2 = " " ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { if ( countChar [ i ] > 1 ) { str2 = str2 + ( char ) ( i + ' a ' ) ; } else if ( countChar [ i ] == 1 ) { str1 = str1 + ( char ) ( i + ' a ' ) ; } } Console . Write ( " String ▁ with ▁ characters ▁ " + " occurring ▁ once : STRNEWLINE " ) ; Console . Write ( str1 + " STRNEWLINE " ) ; Console . Write ( " String ▁ with ▁ characters ▁ occurring ▁ " + " multiple ▁ times : STRNEWLINE " ) ; Console . Write ( str2 + " STRNEWLINE " ) ; Console . Write ( " " ) ; } public static void Main ( ) { string str = " lovetocode " ; printDuo ( str ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void reverse ( char [ ] num , int i , int j ) { while ( i < j ) { char temp = num [ i ] ; num [ i ] = num [ j ] ; num [ j ] = temp ; i ++ ; j -- ; } } public static void nextPalin ( char [ ] num , int n ) { if ( n <= 3 ) { Console . WriteLine ( " Not ▁ Possible " ) ; return ; } char temp ; int mid = n / 2 - 1 ; int i , j ; for ( i = mid - 1 ; i >= 0 ; i -- ) if ( num [ i ] < num [ i + 1 ] ) break ; if ( i < 0 ) { Console . WriteLine ( " Not ▁ Possible " ) ; return ; } int smallest = i + 1 ; for ( j = i + 2 ; j <= mid ; j ++ ) if ( num [ j ] > num [ i ] && num [ j ] < num [ smallest ] ) smallest = j ; temp = num [ i ] ; num [ i ] = num [ smallest ] ; num [ smallest ] = temp ; temp = num [ n - i - 1 ] ; num [ n - i - 1 ] = num [ n - smallest - 1 ] ; num [ n - smallest - 1 ] = temp ; reverse ( num , i + 1 , mid ) ; if ( n % 2 == 0 ) reverse ( num , mid + 1 , n - i - 2 ) ; else reverse ( num , mid + 2 , n - i - 2 ) ; String result = new String ( num ) ; Console . WriteLine ( " Next ▁ Palindrome : ▁ " + result ) ; } public static void Main ( ) { String str = "4697557964" ; char [ ] num = str . ToCharArray ( ) ; int n = str . Length ; nextPalin ( num , n ) ; } }

Index/key variables: i, j, smallest
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void printRec ( String number , int extraOnes , int remainingPlaces ) { if ( 0 == remainingPlaces ) { Console . Write ( number + " ▁ " ) ; return ; } printRec ( number + "1" , extraOnes + 1 , remainingPlaces - 1 ) ; if ( 0 < extraOnes ) printRec ( number + "0" , extraOnes - 1 , remainingPlaces - 1 ) ; } static void printNums ( int n ) { String str = " " ; printRec ( str , 0 , n ) ; } public static void Main ( ) { int n = 4 ; printNums ( n ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class stem { public static String findstem ( String [ ] arr ) { int n = arr . Length ; String s = arr [ 0 ] ; int len = s . Length ; String res = " " ; for ( int i = 0 ; i < len ; i ++ ) { for ( int j = i + 1 ; j <= len ; j ++ ) { String stem = s . Substring ( i , j - i ) ; int k = 1 ; for ( k = 1 ; k < n ; k ++ ) if ( ! arr [ k ] . Contains ( stem ) ) break ; if ( k == n && res . Length < stem . Length ) res = stem ; } } return res ; } public static void Main ( String [ ] args ) { String [ ] arr = { " grace " , " graceful " , " disgraceful " , " gracefully " } ; String stems = findstem ( arr ) ; Console . WriteLine ( stems ) ; } }

Index/key variables: k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: stem
C# program:
using System ; class GFG { static int MAX_CHAR = 256 ; static bool isPossible ( String s1 , String s2 ) { int [ ] count = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < s2 . Length ; i ++ ) count [ ( int ) s2 [ i ] ] ++ ; for ( int i = 0 ; i < s1 . Length ; i ++ ) { if ( count [ ( int ) s1 [ i ] ] == 0 ) return false ; count [ ( int ) s1 [ i ] ] -- ; } return true ; } public static void Main ( ) { string s1 = " GeeksforGeeks " , s2 = " rteksfoGrdsskGeggehes " ; if ( isPossible ( s1 , s2 ) ) Console . WriteLine ( " Possible " ) ; else Console . WriteLine ( " Not ▁ Possible " ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static String nextHighUsingAtMostOneSwap ( String st ) { char [ ] num = st . ToCharArray ( ) ; int l = num . Length ; int posRMax = l - 1 ; int index = - 1 ; for ( int i = l - 2 ; i >= 0 ; i -- ) { if ( num [ i ] >= num [ posRMax ] ) posRMax = i ; else { index = i ; break ; } } if ( index == - 1 ) return " Not ▁ Possible " ; int greatSmallDgt = - 1 ; for ( int i = l - 1 ; i > index ; i -- ) { if ( num [ i ] > num [ index ] ) { if ( greatSmallDgt == - 1 ) greatSmallDgt = i ; else if ( num [ i ] <= num [ greatSmallDgt ] ) greatSmallDgt = i ; } } char temp = num [ index ] ; num [ index ] = num [ greatSmallDgt ] ; num [ greatSmallDgt ] = temp ; string res = new string ( num ) ; return res ; } public static void Main ( ) { String num = "218765" ; Console . WriteLine ( " Original ▁ number : ▁ " + num ) ; Console . WriteLine ( " Next ▁ higher ▁ number : ▁ " + nextHighUsingAtMostOneSwap ( num ) ) ; } }

Index/key variables: greatSmallDgt, i, index, posRMax
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isVowel ( char c ) { return ( c == ' a ' c == ' e ' c == ' i ' c == ' o ' c == ' u ' ) ; } static int longestVowel ( String str ) { int count = 0 , res = 0 ; char [ ] s = str . ToCharArray ( ) ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( isVowel ( s [ i ] ) ) count ++ ; else { res = Math . Max ( res , count ) ; count = 0 ; } } return Math . Max ( res , count ) ; } public static void Main ( ) { String s = " theeare " ; Console . Write ( longestVowel ( s ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX_CHAR = 26 ; static bool check ( int [ ] freq , int k ) { for ( int i = 0 ; i < MAX_CHAR ; i ++ ) if ( freq [ i ] != 0 && freq [ i ] != k ) return false ; return true ; } static int substrings ( String s , int k ) { for ( int i = 0 ; i < s . Length ; i ++ ) { int [ ] freq = new int [ MAX_CHAR ] ; for ( int j = i ; j < s . Length ; j ++ ) { int index = s [ j ] - ' a ' ; freq [ index ] ++ ; if ( freq [ index ] > k ) break ; else if ( freq [ index ] == k && check ( freq , k ) == true ) res ++ ; } } return res ; } public static void Main ( String [ ] args ) { String s = " aabbcc " ; int k = 2 ; Console . WriteLine ( substrings ( s , k ) ) ; s = " aabbc " ; k = 2 ; Console . WriteLine ( substrings ( s , k ) ) ; } }

Index/key variables: MAX_CHAR, i, index, j
Accumulator variables: i, j, res
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static readonly int MAX_CHARS = 26 ; static void longestSubseqWithK ( String str , int k ) { int n = str . Length ; int [ ] freq = new int [ MAX_CHARS ] ; for ( int i = 0 ; i < n ; i ++ ) { freq [ str [ i ] - ' a ' ] ++ ; } for ( int i = 0 ; i < n ; i ++ ) { if ( freq [ str [ i ] - ' a ' ] >= k ) { Console . Write ( str [ i ] ) ; } } } static public void Main ( ) { String str = " geeksforgeeks " ; int k = 2 ; longestSubseqWithK ( str , k ) ; } }

Index/key variables: MAX_CHARS, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void generate ( HashSet < String > st , String s ) { if ( s . Length == 0 ) { return ; } if ( ! st . Contains ( s ) ) { st . Add ( s ) ; for ( int i = 0 ; i < s . Length ; i ++ ) { String t = s ; t = t . Substring ( 0 , i ) + t . Substring ( i + 1 ) ; generate ( st , t ) ; } } return ; } public static void Main ( String [ ] args ) { String s = " xyz " ; HashSet < String > st = new HashSet < String > ( ) ; generate ( st , s ) ; foreach ( String str in st ) { Console . WriteLine ( str ) ; } } }

Accumulator variables: i
Iterator variables: i, str
Class/struct names: GFG
C# program:
using System ; class GFG { static int countSubstrs ( string str , int i , int j , int n ) { if ( n == 1 ) return 1 ; if ( n <= 0 ) return 0 ; int res = countSubstrs ( str , i + 1 , j , n - 1 ) + countSubstrs ( str , i , j - 1 , n - 1 ) - countSubstrs ( str , i + 1 , j - 1 , n - 2 ) ; if ( str [ i ] == str [ j ] ) res ++ ; return res ; } public static void Main ( ) { string str = " abcab " ; int n = str . Length ; Console . WriteLine ( countSubstrs ( str , 0 , n - 1 , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: res
Class/struct names: GFG
C# program:
using System ; public class GFG { static int countManipulations ( string s1 , string s2 ) { int count = 0 ; int [ ] char_count = new int [ 26 ] ; for ( int i = 0 ; i < s1 . Length ; i ++ ) char_count [ s1 [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < s2 . Length ; i ++ ) char_count [ s2 [ i ] - ' a ' ] -- ; for ( int i = 0 ; i < 26 ; ++ i ) { if ( char_count [ i ] != 0 ) { count += Math . Abs ( char_count [ i ] ) ; } } return count / 2 ; } public static void Main ( ) { string s1 = " ddcf " ; string s2 = " cedk " ; Console . WriteLine ( countManipulations ( s1 , s2 ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int MAX_CHAR = 26 ; static int leastCount ( string s1 , string s2 , int n ) { int [ ] count1 = new int [ MAX_CHAR ] ; int [ ] count2 = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < n ; i ++ ) { count1 [ s1 [ i ] - ' a ' ] += 1 ; count2 [ s2 [ i ] - ' a ' ] += 1 ; } int res = 0 ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { if ( count1 [ i ] != 0 ) { res += Math . Abs ( count1 [ i ] - count2 [ i ] ) ; } } return res ; } static public void Main ( ) { string s1 = " abc " ; string s2 = " cdd " ; int len = s1 . Length ; int res = leastCount ( s1 , s2 , len ) ; Console . WriteLine ( res ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class First_Palin { static int MAX_CHAR = 26 ; static char stringPalindrome ( string A , string B ) { int [ ] countA = new int [ MAX_CHAR ] ; int [ ] countB = new int [ MAX_CHAR ] ; int l1 = A . Length ; int l2 = B . Length ; for ( int i = 0 ; i < l1 ; i ++ ) countA [ A [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < l2 ; i ++ ) countB [ B [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < 26 ; i ++ ) if ( ( countA [ i ] > 1 && countB [ i ] == 0 ) ) return ' A ' ; return ' B ' ; } public static void Main ( ) { string a = " abcdea " ; string b = " bcdesg " ; Console . WriteLine ( stringPalindrome ( a , b ) ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: i
Iterator variables: i
Class/struct names: First_Palin
C# program:
using System ; class GFG { static void printLCSubStr ( String X , String Y , int m , int n ) { int [ , ] LCSuff = new int [ m + 1 , n + 1 ] ; int len = 0 ; int row = 0 , col = 0 ; for ( int i = 0 ; i <= m ; i ++ ) { for ( int j = 0 ; j <= n ; j ++ ) { if ( i == 0 j == 0 ) LCSuff [ i , j ] = 0 ; else if ( X [ i - 1 ] == Y [ j - 1 ] ) { LCSuff [ i , j ] = LCSuff [ i - 1 , j - 1 ] + 1 ; if ( len < LCSuff [ i , j ] ) { len = LCSuff [ i , j ] ; row = i ; col = j ; } } else LCSuff [ i , j ] = 0 ; } } if ( len == 0 ) { Console . Write ( " No ▁ Common ▁ Substring " ) ; return ; } String resultStr = " " ; while ( LCSuff [ row , col ] != 0 ) { -- len ; row -- ; col -- ; } Console . WriteLine ( resultStr ) ; } public static void Main ( ) { String X = " OldSite : GeeksforGeeks . org " ; String Y = " NewSite : GeeksQuiz . com " ; int m = X . Length ; int n = Y . Length ; printLCSubStr ( X , Y , m , n ) ; } }

Accumulator variables: col, i, j, row
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void substringConversions ( String str , int k , int b ) { for ( int i = 0 ; i + k <= str . Length ; i ++ ) { String sub = str . Substring ( i , k ) ; int sum = 0 , counter = 0 ; for ( int j = sub . Length - 1 ; j >= 0 ; j -- ) { sum = ( int ) ( sum + ( ( sub [ j ] - '0' ) * Math . Pow ( b , counter ) ) ) ; counter ++ ; } Console . Write ( sum + " ▁ " ) ; } } public static void Main ( String [ ] args ) { String str = "12212" ; int b = 3 , k = 3 ; substringConversions ( str , b , k ) ; } }

Index/key variables: j
Accumulator variables: counter, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { private static int LPCRec ( string curr_str , int count , int len , string str ) { if ( string . ReferenceEquals ( curr_str , null ) curr_str . Length == 0 ) { return ( 0 ) ; } if ( curr_str . Length <= 1 ) { if ( count != 0 && str . Length - len <= 1 ) { return ( count + 1 ) ; } else { return ( 1 ) ; } } int n = curr_str . Length ; for ( int i = 0 ; i < n / 2 ; i ++ ) { if ( curr_str . Substring ( 0 , i + 1 ) . Equals ( curr_str . Substring ( n - 1 - i , n - ( n - 1 - i ) ) ) ) { return LPCRec ( curr_str . Substring ( i + 1 , ( n - 1 - i ) - ( i + 1 ) ) , count + 2 , len + ( i + 1 ) * 2 , str ) ; } } return count + 1 ; } public static int LPC ( string str ) { return LPCRec ( str , 0 , 0 , str ) ; } public static void Main ( string [ ] args ) { Console . WriteLine ( " V ▁ : ▁ " + LPC ( " V " ) ) ; Console . WriteLine ( " VOLVO ▁ : ▁ " + LPC ( " VOLVO " ) ) ; Console . WriteLine ( " VOLVOV ▁ : ▁ " + LPC ( " VOLVOV " ) ) ; Console . WriteLine ( " ghiabcdefhelloadamhelloabcdefghi ▁ : ▁ " + LPC ( " ghiabcdefhelloadamhelloabcdefghi " ) ) ; Console . WriteLine ( " ghiabcdefhelloadamhelloabcdefghik ▁ : ▁ " + LPC ( " ghiabcdefhelloadamhelloabcdefghik " ) ) ; Console . WriteLine ( " antaprezatepzapreanta ▁ : ▁ " + LPC ( " antaprezatepzapreanta " ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX_CHAR = 256 ; static int countBalance ( string s ) { int [ ] rightVisited = new int [ MAX_CHAR ] ; int [ ] leftVisited = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < n ; i ++ ) rightVisited [ s [ i ] ] ++ ; int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { leftVisited [ s [ i ] ] ++ ; rightVisited [ s [ i ] ] -- ; int j ; for ( j = 0 ; j < MAX_CHAR ; j ++ ) { if ( ( leftVisited [ j ] == 0 && rightVisited [ j ] != 0 ) || ( leftVisited [ j ] != 0 && rightVisited [ j ] == 0 ) ) break ; } if ( j == MAX_CHAR ) res ++ ; } return res ; } public static void Main ( String [ ] args ) { string str = " abaababa " ; Console . WriteLine ( countBalance ( str ) ) ; } }

Index/key variables: MAX_CHAR, i, j
Accumulator variables: i, j, res
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static int findFlips ( String str , int n ) { char last = ' ▁ ' ; int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( last != str [ i ] ) res ++ ; last = str [ i ] ; } return res / 2 ; } public static void Main ( ) { String str = "00011110001110" ; int n = str . Length ; Console . Write ( findFlips ( str , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int findLen ( string A , int n , int k , char ch ) { int maxlen = 1 ; int cnt = 0 ; int l = 0 , r = 0 ; while ( r < n ) { if ( A [ r ] != ch ) { ++ cnt ; } while ( cnt > k ) { if ( A [ l ] != ch ) { -- cnt ; } ++ l ; } maxlen = Math . Max ( maxlen , r - l + 1 ) ; ++ r ; } return maxlen ; } public static int answer ( string A , int n , int k ) { int maxlen = 1 ; for ( int i = 0 ; i < 26 ; ++ i ) { maxlen = Math . Max ( maxlen , findLen ( A , n , k , ( char ) ( i + ' A ' ) ) ) ; maxlen = Math . Max ( maxlen , findLen ( A , n , k , ( char ) ( i + ' a ' ) ) ) ; } return maxlen ; } public static void Main ( string [ ] args ) { int n = 5 , k = 2 ; string A = " ABABA " ; Console . WriteLine ( " Maximum ▁ length ▁ = ▁ " + answer ( A , n , k ) ) ; n = 6 ; k = 4 ; string B = " HHHHHH " ; Console . WriteLine ( " Maximum ▁ length ▁ = ▁ " + answer ( B , n , k ) ) ; } }

Index/key variables: l, r
Iterator variables: i
Class/struct names: GFG