dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int minPalPartion ( String str ) { int n = str . Length ; int [ , ] C = new int [ n , n ] ; bool [ , ] P = new bool [ n , n ] ; int i , j , k , L ; for ( i = 0 ; i < n ; i ++ ) { P [ i , i ] = true ; C [ i , i ] = 0 ; } for ( L = 2 ; L <= n ; L ++ ) { for ( i = 0 ; i < n - L + 1 ; i ++ ) { j = i + L - 1 ; if ( L == 2 ) P [ i , j ] = ( str [ i ] == str [ j ] ) ; else P [ i , j ] = ( str [ i ] == str [ j ] ) && P [ i + 1 , j - 1 ] ; if ( P [ i , j ] == true ) C [ i , j ] = 0 ; else { C [ i , j ] = int . MaxValue ; for ( k = i ; k <= j - 1 ; k ++ ) C [ i , j ] = Math . Min ( C [ i , j ] , C [ i , k ] + C [ k + 1 , j ] + 1 ) ; } } } return C [ 0 , n - 1 ] ; } public static void Main ( ) { String str = " ababbbabbababa " ; Console . Write ( " Min ▁ cuts ▁ needed ▁ for ▁ " + " Palindrome ▁ Partitioning ▁ is ▁ " + minPalPartion ( str ) ) ; } }

Index/key variables: i, j
Accumulator variables: L, i, k
Iterator variables: L, i, k
Class/struct names: GFG
C# program:
using System ; public class GFG { public class Node { public int data ; public Node left , right ; } public class INT { public int v ; public INT ( int a ) { v = a ; } } public static Node getNode ( int data ) { Node newNode = new Node ( ) ; newNode . data = data ; newNode . left = newNode . right = null ; return newNode ; } public static int countSubtreesWithSumX ( Node root , INT count , int x ) { if ( root == null ) { return 0 ; } int ls = countSubtreesWithSumX ( root . left , count , x ) ; int rs = countSubtreesWithSumX ( root . right , count , x ) ; int sum = ls + rs + root . data ; if ( sum == x ) { count . v ++ ; } return sum ; } public static int countSubtreesWithSumXUtil ( Node root , int x ) { if ( root == null ) { return 0 ; } INT count = new INT ( 0 ) ; int ls = countSubtreesWithSumX ( root . left , count , x ) ; int rs = countSubtreesWithSumX ( root . right , count , x ) ; if ( ( ls + rs + root . data ) == x ) { count . v ++ ; } return count . v ; } public static void Main ( string [ ] args ) { Node root = getNode ( 5 ) ; root . left = getNode ( - 10 ) ; root . right = getNode ( 3 ) ; root . left . left = getNode ( 9 ) ; root . left . right = getNode ( 8 ) ; root . right . left = getNode ( - 4 ) ; root . right . right = getNode ( 7 ) ; int x = 7 ; Console . WriteLine ( " Count ▁ = ▁ " + countSubtreesWithSumXUtil ( root , x ) ) ; } }

Accumulator variables: v
Class/struct names: GFG, INT, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { static void minchanges ( int [ , ] mat ) { int N = mat . GetLength ( 0 ) ; int M = mat . GetLength ( 1 ) ; int i , j , ans = 0 , x ; Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( i = 0 ; i < N / 2 ; i ++ ) { for ( j = 0 ; j < M / 2 ; j ++ ) { if ( mp . ContainsKey ( mat [ i , M - 1 - j ] ) ) { mp [ mat [ i , M - 1 - j ] ] = mp [ mat [ i , M - 1 - j ] ] + 1 ; } else { mp . Add ( mat [ i , M - 1 - j ] , 1 ) ; } if ( mp . ContainsKey ( mat [ i , j ] ) ) { mp [ mat [ i , j ] ] = mp [ mat [ i , j ] ] + 1 ; } else { mp . Add ( mat [ i , j ] , 1 ) ; } if ( mp . ContainsKey ( mat [ N - 1 - i , M - 1 - j ] ) ) { mp [ mat [ N - 1 - i , M - 1 - j ] ] = mp [ mat [ N - 1 - i , M - 1 - j ] ] + 1 ; } else { mp . Add ( mat [ N - 1 - i , M - 1 - j ] , 1 ) ; } if ( mp . ContainsKey ( mat [ N - 1 - i , j ] ) ) { mp [ mat [ N - 1 - i , j ] ] = mp [ mat [ N - 1 - i , j ] ] + 1 ; } else { mp . Add ( mat [ N - 1 - i , j ] , 1 ) ; } x = 0 ; foreach ( KeyValuePair < int , int > it in mp ) { x = Math . Max ( x , it . Value ) ; } ans = ans + 4 - x ; mp . Clear ( ) ; } } if ( N % 2 == 1 ) { for ( i = 0 ; i < M / 2 ; i ++ ) { if ( mat [ N / 2 , i ] != mat [ N / 2 , M - 1 - i ] ) ans ++ ; } } if ( M % 2 == 1 ) { for ( i = 0 ; i < N / 2 ; i ++ ) { if ( mat [ i , M / 2 ] != mat [ N - 1 - i , M / 2 ] ) ans ++ ; } } Console . Write ( ans ) ; } public static void Main ( String [ ] args ) { int [ , ] mat = { { 1 , 2 , 3 } , { 4 , 5 , 3 } , { 1 , 2 , 1 } } ; minchanges ( mat ) ; } }

Accumulator variables: ans, i, j
Iterator variables: i, it, j
Class/struct names: GFG
C# program:
using System . Threading ; using System . Globalization ; using System ; class GFG { static void checkprefix ( int A , int B ) { string s1 = A . ToString ( ) ; string s2 = B . ToString ( ) ; bool result ; result = s1 . StartsWith ( s2 , false , CultureInfo . InvariantCulture ) ; if ( result ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } static void Main ( ) { int A = 12345 , B = 12 ; checkprefix ( A , B ) ; } }

Class/struct names: GFG
C# program:
using System ; public class Node { public int data ; public Node left ; public Node right ; public Node ( int data ) { this . data = data ; } } class GFG { static int count = 0 ; static Node ptr ; int countSubtreesWithSumXUtil ( Node root , int x ) { int l = 0 , r = 0 ; if ( root == null ) return 0 ; l += countSubtreesWithSumXUtil ( root . left , x ) ; r += countSubtreesWithSumXUtil ( root . right , x ) ; if ( l + r + root . data == x ) count ++ ; if ( ptr != root ) return l + root . data + r ; return count ; } public static void Main ( string [ ] args ) { Node root = new Node ( 5 ) ; root . left = new Node ( - 10 ) ; root . right = new Node ( 3 ) ; root . left . left = new Node ( 9 ) ; root . left . right = new Node ( 8 ) ; root . right . left = new Node ( - 4 ) ; root . right . right = new Node ( 7 ) ; int x = 7 ; ptr = root ; Console . Write ( " Count ▁ = ▁ " + new GFG ( ) . countSubtreesWithSumXUtil ( root , x ) ) ; } }

Accumulator variables: count, l, r
Class/struct names: GFG, Node
C# program:
using System ; class Count_Flips { static int count_flips ( int [ ] a , int n , int k ) { bool set = false ; int ans = 0 , min_diff = int . MaxValue ; for ( int i = 0 ; i < k ; i ++ ) { int curr_index = i , segment = 0 , count_zero = 0 , count_one = 0 ; while ( curr_index < n ) { if ( segment % 2 == 0 ) { if ( a [ curr_index ] == 1 ) count_zero ++ ; else count_one ++ ; } else { if ( a [ curr_index ] == 0 ) count_zero ++ ; else count_one ++ ; } curr_index = curr_index + k ; segment ++ ; } ans += Math . Min ( count_one , count_zero ) ; if ( count_one < count_zero ) set = ! set ; min_diff = Math . Min ( min_diff , Math . Abs ( count_zero - count_one ) ) ; } if ( set ) return ans ; else return ans + min_diff ; } public static void Main ( string [ ] args ) { int n = 6 , k = 3 ; int [ ] a = { 0 , 0 , 1 , 1 , 0 , 0 } ; Console . WriteLine ( count_flips ( a , n , k ) ) ; } }

Index/key variables: curr_index
Accumulator variables: ans, count_one, count_zero, i, segment
Iterator variables: i
Boolean variables: set
Class/struct names: Count_Flips
C# program:
using System ; using System . Collections . Generic ; public class GFG { public class Node { public int data ; public Node left , right ; public Node ( int data ) { this . data = data ; this . left = this . right = null ; } } ; static int size ( Node node ) { if ( node == null ) return 0 ; else return ( size ( node . left ) + 1 + size ( node . right ) ) ; } static bool checkIsAP ( double [ ] arr , int n ) { if ( n == 1 ) return true ; Array . Sort ( arr ) ; double d = arr [ 1 ] - arr [ 0 ] ; for ( int i = 2 ; i < n ; i ++ ) if ( arr [ i ] - arr [ i - 1 ] != d ) return false ; return true ; } static bool checkIsGP ( double [ ] arr , int n ) { if ( n == 1 ) return true ; Array . Sort ( arr ) ; double r = arr [ 1 ] / arr [ 0 ] ; for ( int i = 2 ; i < n ; i ++ ) { if ( arr [ i ] / arr [ i - 1 ] != r ) return false ; } return true ; } static bool checkIsHP ( double [ ] arr , int n ) { if ( n == 1 ) { return true ; } double [ ] rec = new double [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { rec [ i ] = ( ( 1 / arr [ i ] ) ) ; } Array . Sort ( rec ) ; double d = ( rec [ 1 ] ) - ( rec [ 0 ] ) ; for ( int i = 2 ; i < n ; i ++ ) { if ( rec [ i ] - rec [ i - 1 ] != d ) { return false ; } } return true ; } static void checktype ( Node root ) { int n = size ( root ) ; double [ ] arr = new double [ n ] ; int i = 0 ; if ( root == null ) return ; Queue < Node > q = new Queue < Node > ( ) ; q . Enqueue ( root ) ; while ( q . Count != 0 == false ) { Node node = q . Dequeue ( ) ; arr [ i ] = node . data ; i ++ ; if ( node . left != null ) q . Enqueue ( node . left ) ; if ( node . right != null ) q . Enqueue ( node . right ) ; } int flag = 0 ; if ( checkIsAP ( arr , n ) ) { Console . WriteLine ( " Arithmetic ▁ Progression " ) ; flag = 1 ; } else if ( checkIsGP ( arr , n ) ) { Console . WriteLine ( " Geometric ▁ Progression " ) ; flag = 1 ; } else if ( checkIsHP ( arr , n ) ) { Console . WriteLine ( " Geometric ▁ Progression " ) ; flag = 1 ; } else if ( flag == 0 ) { Console . WriteLine ( " No " ) ; } } public static void Main ( String [ ] args ) { Node root = new Node ( 1 ) ; root . left = new Node ( 2 ) ; root . right = new Node ( 3 ) ; root . left . left = new Node ( 4 ) ; root . left . right = new Node ( 5 ) ; root . right . right = new Node ( 8 ) ; root . right . right . left = new Node ( 6 ) ; root . right . right . right = new Node ( 7 ) ; checktype ( root ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Node
C# program:
using System ; class GFG { static void q1 ( string s , int i ) { Console . Write ( " q1 - > " ) ; if ( i == s . Length ) { Console . WriteLine ( " NO " ) ; return ; } if ( s [ i ] == '0' ) q1 ( s , i + 1 ) ; else q3 ( s , i + 1 ) ; } static void q2 ( string s , int i ) { Console . Write ( " q2 - > " ) ; if ( i == s . Length ) { Console . WriteLine ( " NO ▁ " ) ; return ; } if ( s [ i ] == '0' ) q4 ( s , i + 1 ) ; else q2 ( s , i + 1 ) ; } static void q3 ( string s , int i ) { Console . Write ( " q3 - > " ) ; if ( i == s . Length ) { Console . WriteLine ( " YES " ) ; return ; } if ( s [ i ] == '0' ) q4 ( s , i + 1 ) ; else q2 ( s , i + 1 ) ; } static void q4 ( string s , int i ) { Console . Write ( " q4 - > " ) ; if ( i == s . Length ) { Console . WriteLine ( " YES " ) ; return ; } if ( s [ i ] == '0' ) q1 ( s , i + 1 ) ; else q3 ( s , i + 1 ) ; } static void q0 ( string s , int i ) { Console . Write ( " q0 - > " ) ; if ( i == s . Length ) { Console . WriteLine ( " NO " ) ; return ; } if ( s [ i ] == '0' ) q1 ( s , i + 1 ) ; else q2 ( s , i + 1 ) ; } public static void Main ( ) { string s = "010101" ; Console . Write ( " State ▁ transitions ▁ are ▁ " ) ; q0 ( s , 0 ) ; } }

Index/key variables: i
Class/struct names: GFG
C# program:
using System ; public class temp { public static bool checkSequence ( String a , String b ) { if ( b . Length == 0 ) return true ; if ( a . Length == 0 ) return false ; if ( a [ 0 ] == b [ 0 ] ) return checkSequence ( a . Substring ( 1 ) , b . Substring ( 1 ) ) ; else return checkSequence ( a . Substring ( 1 ) , b ) ; } public static void Main ( String [ ] args ) { String s1 = " Geeks " , s2 = " Geks " ; if ( checkSequence ( s1 , s2 ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Class/struct names: temp
C# program:
using System ; class GfG { public static int doMatch ( String A , String B ) { for ( int i = 0 ; i < A . Length ; i ++ ) { if ( A [ i ] != ' * ' && B [ i ] != ' * ' ) if ( A [ i ] != B [ i ] ) return 0 ; } return 1 ; } public static void Main ( String [ ] args ) { String A = " gee * sforgeeks " ; String B = " geeksforgeeks " ; Console . WriteLine ( doMatch ( A , B ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GfG
C# program:
using System ; class gfg { public int nthTerm ( int N ) { int n = ( ( N + N * ( N - 1 ) ) / 2 ) ; return n ; } static void Main ( string [ ] args ) { gfg p = new gfg ( ) ; int a = p . nthTerm ( 5 ) ; Console . WriteLine ( a ) ; Console . Read ( ) ; } }

Class/struct names: gfg
C# program:
using System ; class GFG { static int countSubstrs ( String s1 , String s2 ) { int ans = 0 ; for ( int i = 0 ; i < s1 . Length ; i ++ ) { String s3 = " " ; char [ ] s4 = s1 . ToCharArray ( ) ; for ( int j = i ; j < s1 . Length ; j ++ ) { s3 += s4 [ j ] ; if ( s2 . IndexOf ( s3 ) != - 1 ) ans ++ ; } } return ans ; } public static void Main ( String [ ] args ) { String s1 = " aab " , s2 = " aaaab " ; Console . WriteLine ( countSubstrs ( s1 , s2 ) ) ; } }

Index/key variables: j
Accumulator variables: ans, i, j, s3
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int factorial ( int N ) { int fact = 1 ; for ( int i = 1 ; i <= N ; i ++ ) fact = fact * i ; return fact ; } static int nthTerm ( int N ) { return ( factorial ( N ) * ( N + 2 ) / 2 ) ; } public static void Main ( ) { int N = 6 ; Console . Write ( nthTerm ( N ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int sum = 0 , max_level = int . MinValue ; public class Node { public int d ; public Node l ; public Node r ; } ; static Node createNode ( int d ) { Node node ; node = new Node ( ) ; node . d = d ; node . l = null ; node . r = null ; return node ; } static void sumOfNodesAtMaxDepth ( Node ro , int level ) { if ( ro == null ) return ; if ( level > max_level ) { sum = ro . d ; max_level = level ; } else if ( level == max_level ) { sum = sum + ro . d ; } sumOfNodesAtMaxDepth ( ro . l , level + 1 ) ; sumOfNodesAtMaxDepth ( ro . r , level + 1 ) ; } public static void Main ( String [ ] args ) { Node root ; root = createNode ( 1 ) ; root . l = createNode ( 2 ) ; root . r = createNode ( 3 ) ; root . l . l = createNode ( 4 ) ; root . l . r = createNode ( 5 ) ; root . r . l = createNode ( 6 ) ; root . r . r = createNode ( 7 ) ; sumOfNodesAtMaxDepth ( root , 0 ) ; Console . WriteLine ( sum ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; class GFG { public static bool regexMatch ( String text , String pat ) { int lenText = text . Length ; int lenPat = pat . Length ; char [ ] Text = text . ToCharArray ( ) ; char [ ] Pat = pat . ToCharArray ( ) ; int i = 0 , j = 0 ; while ( i < lenPat ) { if ( Pat [ i ] != ' # ' ) { if ( Pat [ i ] != Text [ j ] ) return false ; i ++ ; j ++ ; } else { j ++ ; while ( Text [ j ] != Pat [ i + 1 ] ) j ++ ; i ++ ; } } return ( j == lenText ) ; } public static void Main ( ) { String str = " ABABABA " ; String pat = " A # B # A " ; if ( regexMatch ( str , pat ) ) Console . Write ( " yes " ) ; else Console . Write ( " no " ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void translate ( char [ ] str ) { int len = str . Length ; if ( len < 2 ) return ; int i = 0 ; int j = 0 ; while ( j < len - 1 ) { if ( str [ j ] == ' A ' && str [ j + 1 ] == ' B ' ) { j = j + 2 ; str [ i ++ ] = ' C ' ; continue ; } str [ i ++ ] = str [ j ++ ] ; } if ( j == len - 1 ) str [ i ++ ] = str [ j ] ; str [ i ] = ' ▁ ' ; str [ len - 1 ] = ' ▁ ' ; } public static void Main ( ) { String st = " helloABworldABGfG " ; char [ ] str = st . ToCharArray ( ) ; translate ( str ) ; Console . Write ( " The ▁ modified ▁ string ▁ is ▁ : " ) ; Console . Write ( str ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int R , C ; static int [ ] x = { - 1 , - 1 , - 1 , 0 , 0 , 1 , 1 , 1 } ; static int [ ] y = { - 1 , 0 , 1 , - 1 , 1 , - 1 , 0 , 1 } ; static bool search2D ( char [ , ] grid , int row , int col , String word ) { if ( grid [ row , col ] != word [ 0 ] ) { return false ; } int len = word . Length ; for ( int dir = 0 ; dir < 8 ; dir ++ ) { int k , rd = row + x [ dir ] , cd = col + y [ dir ] ; for ( k = 1 ; k < len ; k ++ ) { if ( rd >= R rd < 0 cd >= C cd < 0 ) { break ; } if ( grid [ rd , cd ] != word [ k ] ) { break ; } rd += x [ dir ] ; cd += y [ dir ] ; } if ( k == len ) { return true ; } } return false ; } static void patternSearch ( char [ , ] grid , String word ) { for ( int row = 0 ; row < R ; row ++ ) { for ( int col = 0 ; col < C ; col ++ ) { if ( search2D ( grid , row , col , word ) ) { Console . WriteLine ( " pattern ▁ found ▁ at ▁ " + row + " , ▁ " + col ) ; } } } } public static void Main ( String [ ] args ) { R = 3 ; C = 13 ; char [ , ] grid = { { ' G ' , ' E ' , ' E ' , ' K ' , ' S ' , ' F ' , ' O ' , ' R ' , ' G ' , ' E ' , ' E ' , ' K ' , ' S ' } , { ' G ' , ' E ' , ' E ' , ' K ' , ' S ' , ' Q ' , ' U ' , ' I ' , ' Z ' , ' G ' , ' E ' , ' E ' , ' K ' } , { ' I ' , ' D ' , ' E ' , ' Q ' , ' A ' , ' P ' , ' R ' , ' A ' , ' C ' , ' T ' , ' I ' , ' C ' , ' E ' } } ; patternSearch ( grid , " GEEKS " ) ; Console . WriteLine ( ) ; patternSearch ( grid , " EEE " ) ; } } is by -

Index/key variables: dir, k
Accumulator variables: cd, col, dir, k, rd, row
Iterator variables: col, dir, k, row
Class/struct names: GFG
C# program:
using System ; public class AWQ { static int NO_OF_CHARS = 256 ; static int max ( int a , int b ) { return ( a > b ) ? a : b ; } static void badCharHeuristic ( char [ ] str , int size , int [ ] badchar ) { int i ; for ( i = 0 ; i < NO_OF_CHARS ; i ++ ) badchar [ i ] = - 1 ; for ( i = 0 ; i < size ; i ++ ) badchar [ ( int ) str [ i ] ] = i ; } static void search ( char [ ] txt , char [ ] pat ) { int m = pat . Length ; int n = txt . Length ; int [ ] badchar = new int [ NO_OF_CHARS ] ; badCharHeuristic ( pat , m , badchar ) ; int s = 0 ; while ( s <= ( n - m ) ) { int j = m - 1 ; while ( j >= 0 && pat [ j ] == txt [ s + j ] ) j -- ; if ( j < 0 ) { Console . WriteLine ( " Patterns ▁ occur ▁ at ▁ shift ▁ = ▁ " + s ) ; s += ( s + m < n ) ? m - badchar [ txt [ s + m ] ] : 1 ; } else s += max ( 1 , j - badchar [ txt [ s + j ] ] ) ; } } public static void Main ( ) { char [ ] txt = " ABAAABCD " . ToCharArray ( ) ; char [ ] pat = " ABC " . ToCharArray ( ) ; search ( txt , pat ) ; } }

Index/key variables: NO_OF_CHARS, i, j
Accumulator variables: i, j, s
Iterator variables: i
Class/struct names: AWQ
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int data ) { this . data = data ; this . left = null ; this . right = null ; } } public class GfG { public static int sumMaxLevelRec ( Node node , int max ) { if ( node == null ) { return 0 ; } if ( max == 1 ) { return node . data ; } return sumMaxLevelRec ( node . left , max - 1 ) + sumMaxLevelRec ( node . right , max - 1 ) ; } public static int maxDepth ( Node node ) { if ( node == null ) { return 0 ; } return 1 + Math . Max ( maxDepth ( node . left ) , maxDepth ( node . right ) ) ; } public static int sumMaxLevel ( Node root ) { int MaxDepth = maxDepth ( root ) ; return sumMaxLevelRec ( root , MaxDepth ) ; } public static void Main ( string [ ] args ) { Node root = new Node ( 1 ) ; root . left = new Node ( 2 ) ; root . right = new Node ( 3 ) ; root . left . left = new Node ( 4 ) ; root . left . right = new Node ( 5 ) ; root . right . left = new Node ( 6 ) ; root . right . right = new Node ( 7 ) ; Console . WriteLine ( sumMaxLevel ( root ) ) ; } }

Class/struct names: GfG, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { static void SumofDistances ( string s ) { List < int > [ ] v = new List < int > [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) v [ i ] = new List < int > ( ) ; for ( int i = 0 ; i < s . Length ; i ++ ) { v [ ( int ) s [ i ] - 97 ] . Add ( i ) ; } int ans = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { int sum = 0 ; for ( int j = 0 ; j < v [ i ] . Count ; j ++ ) { sum += v [ i ] [ j ] ; } for ( int j = 0 ; j < v [ i ] . Count ; j ++ ) { sum -= v [ i ] [ j ] ; ans += ( sum - ( v [ i ] . Count - 1 - j ) * ( v [ i ] [ j ] ) ) ; } } Console . Write ( ans ) ; } public static void Main ( ) { string s = " ababa " ; SumofDistances ( s ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findOperations ( String A , String B , int N ) { int operations = 0 ; List < int > ops = new List < int > ( ) ; bool invert = false ; for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( A [ i ] != B [ i ] ) { if ( ! invert ) { operations ++ ; ops . Add ( i + 1 ) ; invert = true ; } } else { if ( invert ) { operations ++ ; ops . Add ( i + 1 ) ; invert = false ; } } } Console . Write ( operations + " STRNEWLINE " ) ; if ( operations != 0 ) { foreach ( int x in ops ) Console . Write ( x + " ▁ " ) ; } } public static void Main ( String [ ] args ) { String A = "001" , B = "000" ; int N = A . Length ; findOperations ( A , B , N ) ; } }

Index/key variables: i
Accumulator variables: i, operations
Iterator variables: i, x
Boolean variables: invert
Class/struct names: GFG
C# program:
using System ; using System . Linq ; class GFG { public static int maxScoreWords ( string [ ] words , char [ ] letters , int [ ] score ) { int [ ] letterCounts = new int [ 26 ] ; foreach ( char letter in letters ) letterCounts [ letter - ' a ' ] ++ ; return helper ( words , 0 , letterCounts , score ) ; } public static int helper ( string [ ] words , int start , int [ ] letterCounts , int [ ] score ) { if ( start == words . Length ) return 0 ; int currScore = 0 ; int wordScore = 0 ; int [ ] nextCounts = letterCounts . ToArray ( ) ; for ( int i = 0 ; i < words [ start ] . Length ; ++ i ) { int idx = words [ start ] [ i ] - ' a ' ; if ( nextCounts [ idx ] == 0 ) { wordScore = - 1 ; break ; } wordScore += score [ idx ] ; nextCounts [ idx ] -- ; } if ( wordScore > 0 ) currScore = helper ( words , start + 1 , nextCounts , score ) + wordScore ; currScore = Math . Max ( currScore , helper ( words , start + 1 , letterCounts , score ) ) ; return currScore ; } public static void Main ( string [ ] args ) { string [ ] words = { " dog " , " cat " , " dad " , " good " } ; char [ ] letters = { ' a ' , ' a ' , ' c ' , ' d ' , ' d ' , ' d ' , ' g ' , ' o ' , ' o ' } ; int [ ] score = { 1 , 0 , 9 , 5 , 0 , 0 , 3 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 2 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ; Console . WriteLine ( maxScoreWords ( words , letters , score ) ) ; } }

Index/key variables: i, idx, start
Accumulator variables: wordScore
Iterator variables: i, letter
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void countFrequency ( string S , int N ) { int [ ] freq = new int [ 26 ] ; Array . Clear ( freq , 0 , freq . Length ) ; for ( int i = 0 ; i < N ; i ++ ) { freq [ ( int ) S [ i ] - ' a ' ] += 1 ; } for ( int i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] == 0 ) continue ; int lg = ( int ) Math . Log ( ( double ) freq [ i ] , 2.0 ) ; int a = ( int ) Math . Pow ( 2 , lg ) ; if ( a == freq [ i ] ) { while ( freq [ i ] > 0 ) { freq [ i ] -= 1 ; Console . Write ( ( char ) ( i + ' a ' ) ) ; } } } } public static void Main ( ) { string S = " aaacbb " ; int N = S . Length ; countFrequency ( S , N ) ; } }

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