dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; public class SortExample { static void printOrder ( int [ ] arr , int k ) { int n = arr . Length ; Array . Sort ( arr , 0 , k ) ; Array . Sort ( arr , k , n - k ) ; Array . Reverse ( arr , k , n - k ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 4 , 6 , 2 , 1 , 3 , 8 , 9 , - 1 } ; int k = 4 ; printOrder ( arr , k ) ; Console . Write ( " { 0 } " , String . Join ( " ▁ " , arr ) ) ; } }

Class/struct names: SortExample
C# program:
using System ; using System . Collections . Generic ; public class maxwidthusingqueue { public class node { public int data ; public node left , right ; public node ( int data ) { this . data = data ; } } static int maxwidth ( node root ) { if ( root == null ) return 0 ; int maxwidth = 0 ; Queue < node > q = new Queue < node > ( ) ; q . Enqueue ( root ) ; while ( q . Count != 0 ) { int count = q . Count ; maxwidth = Math . Max ( maxwidth , count ) ; while ( count -- > 0 ) { node temp = q . Dequeue ( ) ; if ( temp . left != null ) { q . Enqueue ( temp . left ) ; } if ( temp . right != null ) { q . Enqueue ( temp . right ) ; } } } return maxwidth ; } 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 ) ; Console . WriteLine ( " Maximum ▁ width ▁ = ▁ " + maxwidth ( root ) ) ; } }

Accumulator variables: count
Class/struct names: maxwidthusingqueue, node
C# program:
using System ; using System . Collections . Generic ; class GFG { static Stack < int > sortStack ( ref Stack < int > input ) { Stack < int > tmpStack = new Stack < int > ( ) ; while ( input . Count != 0 ) { int tmp = input . Peek ( ) ; input . Pop ( ) ; while ( tmpStack . Count != 0 && tmpStack . Peek ( ) > tmp ) { input . Push ( tmpStack . Peek ( ) ) ; tmpStack . Pop ( ) ; } tmpStack . Push ( tmp ) ; } return tmpStack ; } static Stack < int > sortedMerge ( ref Stack < int > s1 , ref Stack < int > s2 ) { Stack < int > res = new Stack < int > ( ) ; while ( s1 . Count != 0 ) { res . Push ( s1 . Peek ( ) ) ; s1 . Pop ( ) ; } while ( s2 . Count != 0 ) { res . Push ( s2 . Peek ( ) ) ; s2 . Pop ( ) ; } return sortStack ( ref res ) ; } static void Main ( ) { Stack < int > s1 = new Stack < int > ( ) ; Stack < int > s2 = new Stack < int > ( ) ; s1 . Push ( 34 ) ; s1 . Push ( 3 ) ; s1 . Push ( 31 ) ; s2 . Push ( 1 ) ; s2 . Push ( 12 ) ; s2 . Push ( 23 ) ; Stack < int > tmpStack = new Stack < int > ( ) ; tmpStack = sortedMerge ( ref s1 , ref s2 ) ; Console . Write ( " Sorted ▁ and ▁ merged ▁ stack ▁ : STRNEWLINE " ) ; while ( tmpStack . Count != 0 ) { Console . Write ( tmpStack . Peek ( ) + " ▁ " ) ; tmpStack . Pop ( ) ; } } }

Class/struct names: GFG
C# program:
using System ; class GFG { static String lexicographicSubConcat ( String s ) { int n = s . Length ; int sub_count = n * ( n + 1 ) / 2 ; String [ ] arr = new String [ sub_count ] ; int index = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int len = 1 ; len <= n - i ; len ++ ) { arr [ index ++ ] = s . Substring ( i , len ) ; } Array . Sort ( arr ) ; String res = " " ; for ( int i = 0 ; i < sub_count ; i ++ ) res += arr [ i ] ; return res ; } public static void Main ( String [ ] args ) { String s = " abc " ; Console . WriteLine ( lexicographicSubConcat ( s ) ) ; } }

Index/key variables: i, sub_count
Accumulator variables: i, index, len, res
Iterator variables: i, len
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void printVector ( List < int > V ) { for ( int i = 0 ; i < V . Count ; i ++ ) { Console . Write ( V [ i ] + " ▁ " ) ; } Console . WriteLine ( ) ; } static void insertionSort ( List < int > V ) { int N = V . Count ; int i , j ; for ( i = 1 ; i < N ; i ++ ) { j = i ; while ( j > 0 && V [ j ] < V [ j - 1 ] ) { int temp = V [ j ] ; V [ j ] = V [ j - 1 ] ; V [ j - 1 ] = temp ; j -= 1 ; } } } public static void Main ( String [ ] args ) { List < int > A = new List < int > ( ) ; A . Insert ( 0 , 9 ) ; A . Insert ( 1 , 8 ) ; A . Insert ( 2 , 7 ) ; A . Insert ( 3 , 5 ) ; A . Insert ( 4 , 2 ) ; A . Insert ( 5 , 1 ) ; A . Insert ( 6 , 2 ) ; A . Insert ( 7 , 3 ) ; Console . Write ( " Array : ▁ STRNEWLINE " ) ; printVector ( A ) ; Console . Write ( " After ▁ Sorting ▁ : STRNEWLINE " ) ; insertionSort ( A ) ; printVector ( A ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void descOrder ( char [ ] s ) { Array . Sort ( s ) ; reverse ( s ) ; } static void reverse ( char [ ] a ) { int i , n = a . Length ; char t ; for ( i = 0 ; i < n / 2 ; i ++ ) { t = a [ i ] ; a [ i ] = a [ n - i - 1 ] ; a [ n - i - 1 ] = t ; } } public static void Main ( String [ ] args ) { char [ ] s = " geeksforgeeks " . ToCharArray ( ) ; Console . WriteLine ( String . Join ( " " , s ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int MAX = 1000 ; static int findDuplicate ( int [ ] arr , int n , int k ) { int [ ] freq = new int [ MAX ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < 1 && arr [ i ] > MAX ) { Console . WriteLine ( " Out ▁ of ▁ range " ) ; return - 1 ; } freq [ arr [ i ] ] += 1 ; } for ( int i = 0 ; i < MAX ; i ++ ) { if ( freq [ i ] == k ) return i ; } return - 1 ; } public static void Main ( ) { int [ ] arr = { 2 , 2 , 1 , 3 , 1 } ; int k = 2 ; int n = arr . Length ; Console . WriteLine ( findDuplicate ( arr , n , k ) ) ; } }

Index/key variables: MAX, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static String isKSortedArray ( int [ ] arr , int n , int k ) { int [ ] aux = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) aux [ i ] = arr [ i ] ; Array . Sort ( aux ) ; for ( int i = 0 ; i < n ; i ++ ) { int j = Array . BinarySearch ( aux , arr [ i ] ) ; if ( Math . Abs ( i - j ) > k ) return " No " ; } return " Yes " ; } public static void Main ( ) { int [ ] arr = { 3 , 2 , 1 , 5 , 6 , 4 } ; int k = 2 ; Console . WriteLine ( " Is ▁ it ▁ a ▁ k ▁ sorted ▁ array ▁ ? : ▁ " + isKSortedArray ( arr , arr . Length , k ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public const int RUN = 32 ; public static void insertionSort ( int [ ] arr , int left , int right ) { for ( int i = left + 1 ; i <= right ; i ++ ) { int temp = arr [ i ] ; int j = i - 1 ; while ( j >= left && arr [ j ] > temp ) { arr [ j + 1 ] = arr [ j ] ; j -- ; } arr [ j + 1 ] = temp ; } } public static void merge ( int [ ] arr , int l , int m , int r ) { int len1 = m - l + 1 , len2 = r - m ; int [ ] left = new int [ len1 ] ; int [ ] right = new int [ len2 ] ; for ( int x = 0 ; x < len1 ; x ++ ) left [ x ] = arr [ l + x ] ; for ( int x = 0 ; x < len2 ; x ++ ) right [ x ] = arr [ m + 1 + x ] ; int i = 0 ; int j = 0 ; int k = l ; while ( i < len1 && j < len2 ) { if ( left [ i ] <= right [ j ] ) { arr [ k ] = left [ i ] ; i ++ ; } else { arr [ k ] = right [ j ] ; j ++ ; } k ++ ; } while ( i < len1 ) { arr [ k ] = left [ i ] ; k ++ ; i ++ ; } while ( j < len2 ) { arr [ k ] = right [ j ] ; k ++ ; j ++ ; } } public static void timSort ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i += RUN ) insertionSort ( arr , i , Math . Min ( ( i + RUN - 1 ) , ( n - 1 ) ) ) ; for ( int size = RUN ; size < n ; size = 2 * size ) { for ( int left = 0 ; left < n ; left += 2 * size ) { int mid = left + size - 1 ; int right = Math . Min ( ( left + 2 * size - 1 ) , ( n - 1 ) ) ; if ( mid < right ) merge ( arr , left , mid , right ) ; } } } public static void printArray ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; Console . Write ( " STRNEWLINE " ) ; } public static void Main ( ) { int [ ] arr = { - 2 , 7 , 15 , - 14 , 0 , 15 , 0 , 7 , - 7 , - 4 , - 13 , 5 , 8 , - 14 , 12 } ; int n = arr . Length ; Console . Write ( " Given ▁ Array ▁ is STRNEWLINE " ) ; printArray ( arr , n ) ; timSort ( arr , n ) ; Console . Write ( " After ▁ Sorting ▁ Array ▁ is STRNEWLINE " ) ; printArray ( arr , n ) ; } }

Index/key variables: i, j, k, len1, len2, x
Accumulator variables: i, j, k, left, x
Iterator variables: i, left, size, x
Class/struct names: GFG
C# program:
using System ; class Test { static void pendulumArrangement ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int [ ] op = new int [ n ] ; int mid = ( n - 1 ) / 2 ; int j = 1 , i = 1 ; op [ mid ] = arr [ 0 ] ; for ( i = 1 ; i <= mid ; i ++ ) { op [ mid + i ] = arr [ j ++ ] ; op [ mid - i ] = arr [ j ++ ] ; } if ( n % 2 == 0 ) op [ mid + i ] = arr [ j ] ; Console . Write ( " Pendulum ▁ arrangement : " ) ; for ( i = 0 ; i < n ; i ++ ) Console . Write ( op [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; } public static void Main ( ) { int [ ] arr = { 14 , 6 , 19 , 21 , 12 } ; pendulumArrangement ( arr , arr . Length ) ; } }

Index/key variables: i, j, mid, n
Accumulator variables: i, j
Iterator variables: i
Class/struct names: Test
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } public class BinaryTree { Node root ; int getMaxWidth ( Node node ) { int width ; int h = height ( node ) ; int [ ] count = new int [ 10 ] ; int level = 0 ; getMaxWidthRecur ( node , count , level ) ; return getMax ( count , h ) ; } void getMaxWidthRecur ( Node node , int [ ] count , int level ) { if ( node != null ) { count [ level ] ++ ; getMaxWidthRecur ( node . left , count , level + 1 ) ; getMaxWidthRecur ( node . right , count , level + 1 ) ; } } int height ( Node node ) { if ( node == null ) return 0 ; else { int lHeight = height ( node . left ) ; int rHeight = height ( node . right ) ; return ( lHeight > rHeight ) ? ( lHeight + 1 ) : ( rHeight + 1 ) ; } } int getMax ( int [ ] arr , int n ) { int max = arr [ 0 ] ; int i ; for ( i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > max ) max = arr [ i ] ; } return max ; } public static void Main ( String [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 5 ) ; tree . root . right . right = new Node ( 8 ) ; tree . root . right . right . left = new Node ( 6 ) ; tree . root . right . right . right = new Node ( 7 ) ; Console . WriteLine ( " Maximum ▁ width ▁ is ▁ " + tree . getMaxWidth ( tree . root ) ) ; } }

Index/key variables: i, level
Accumulator variables: i
Iterator variables: i
Class/struct names: BinaryTree, Node
C# program:
using System ; class GFG { static long minValue ( int [ ] a , int [ ] b , int n ) { Array . Sort ( a ) ; Array . Sort ( b ) ; long result = 0 ; for ( int i = 0 ; i < n ; i ++ ) result += ( a [ i ] * b [ n - i - 1 ] ) ; return result ; } public static void Main ( ) { int [ ] a = { 3 , 1 , 1 } ; int [ ] b = { 6 , 5 , 4 } ; int n = a . Length ; Console . Write ( minValue ( a , b , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, result
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int TotalPerfectPowerSum ( long L , long R ) { List < long > pows = new List < long > ( ) ; pows . Add ( 0 ) ; pows . Add ( 1 ) ; for ( int p = 2 ; p < 25 ; p ++ ) { long num = 2 ; while ( ( long ) ( Math . Pow ( num , p ) + 0.5 ) <= R ) { pows . Add ( ( long ) ( Math . Pow ( num , p ) + 0.5 ) ) ; num ++ ; } } int [ ] ok = new int [ R + 2 ] ; for ( int i = 0 ; i < pows . Count ; i ++ ) { for ( int j = 0 ; j < pows . Count ; j ++ ) { if ( pows [ i ] + pows [ j ] <= R && pows [ i ] + pows [ j ] >= L ) { ok [ pows [ i ] + pows [ j ] ] = 1 ; } } } for ( int i = 1 ; i <= R ; i ++ ) { ok [ i ] += ok [ i - 1 ] ; } return ok [ R ] - ok [ L - 1 ] ; } public static void Main ( ) { int L = 5 , R = 8 ; Console . WriteLine ( TotalPerfectPowerSum ( L , R ) ) ; } }

Index/key variables: R, i, j
Accumulator variables: i, j, num, p
Iterator variables: i, j, p
Class/struct names: GFG
C# program:
using System ; public class GFG { class Node { public Node left , right ; public int val ; } static Node newNode ( int data ) { Node newNode = new Node ( ) ; newNode . val = data ; newNode . left = null ; newNode . right = null ; return newNode ; } static int minAbsDiff ( Node root ) { int [ ] minDiff = new int [ 1 ] ; minDiff [ 0 ] = Int32 . MaxValue ; postOrder ( root ) ; preOrder ( root , minDiff ) ; return minDiff [ 0 ] ; } static int postOrder ( Node root ) { if ( root == null ) return 0 ; root . val += postOrder ( root . left ) + postOrder ( root . right ) ; return root . val ; } static void preOrder ( Node root , int [ ] minDiff ) { if ( root == null ) return ; int leftDiff = Math . Abs ( root . left . val - ( root . val - root . left . val ) ) ; int rightDiff = Math . Abs ( root . right . val - ( root . val - root . right . val ) ) ; minDiff [ 0 ] = Math . Min ( minDiff [ 0 ] , Math . Min ( leftDiff , rightDiff ) ) ; return ; } public static void Main ( ) { Node root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 3 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 5 ) ; root . right . left = newNode ( 6 ) ; root . right . right = newNode ( 7 ) ; Console . Write ( minAbsDiff ( root ) ) ; } }

Accumulator variables: val
Class/struct names: GFG, Node
C# program:
using System ; class GFG { public class Node { public int data ; public Node left , right ; } ; static int maximum = 0 , minimum = 0 ; static void lengthUtil ( Node root , int curr ) { if ( root == null ) return ; lengthUtil ( root . left , curr - 1 ) ; if ( minimum > curr ) minimum = curr ; if ( maximum < curr ) maximum = curr ; lengthUtil ( root . right , curr + 1 ) ; } static int getLength ( Node root ) { maximum = 0 ; minimum = 0 ; lengthUtil ( root , 0 ) ; return ( Math . Abs ( minimum ) + maximum ) + 1 ; } static Node newNode ( int data ) { Node curr = new Node ( ) ; curr . data = data ; curr . left = curr . right = null ; return curr ; } public static void Main ( String [ ] args ) { Node root = newNode ( 7 ) ; root . left = newNode ( 6 ) ; root . right = newNode ( 5 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 3 ) ; root . right . left = newNode ( 2 ) ; root . right . right = newNode ( 1 ) ; Console . WriteLine ( getLength ( root ) ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; using System . Collections . Generic ; public class GFG { static void findMaximumSumWithMflips ( int [ ] arr , int N , int M ) { List < int > minHeap = new List < int > ( ) ; int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { minHeap . Add ( arr [ i ] ) ; sum += arr [ i ] ; } minHeap . Sort ( ) ; while ( M -- > 0 ) { sum -= minHeap [ 0 ] ; int temp = - 1 * minHeap [ 0 ] ; minHeap . RemoveAt ( 0 ) ; sum += temp ; minHeap . Add ( temp ) ; minHeap . Sort ( ) ; } Console . WriteLine ( sum ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { - 3 , 7 , - 1 , - 5 , - 3 } ; int M = 4 , N = 5 ; findMaximumSumWithMflips ( arr , N , M ) ; } }

Index/key variables: i
Accumulator variables: M, i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void miniOperToMakeAllEleEqual ( int [ ] arr , int n , int k ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; } if ( sum % n != 0 ) { Console . WriteLine ( - 1 ) ; return ; } int valueAfterDivision = sum / n ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( Math . Abs ( valueAfterDivision - arr [ i ] ) % k != 0 ) { Console . WriteLine ( - 1 ) ; return ; } count += Math . Abs ( valueAfterDivision - arr [ i ] ) / k ; } Console . WriteLine ( ( int ) count / 2 ) ; } static void Main ( ) { int n = 3 , k = 3 ; int [ ] arr = { 5 , 8 , 11 } ; miniOperToMakeAllEleEqual ( arr , n , k ) ; } }

Index/key variables: i
Accumulator variables: count, i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void minOperations ( List < int > a ) { int res = Int32 . MaxValue ; int N = a . Count ; for ( int r = 0 ; r < 2 ; r ++ ) { int sum = 0 , ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += a [ i ] ; if ( ( i + r ) % 2 == 1 ) { if ( sum <= 0 ) { ans += - sum + 1 ; sum = 1 ; } } else { if ( sum >= 0 ) { ans += sum + 1 ; sum = - 1 ; } } } res = Math . Min ( res , ans ) ; } Console . Write ( res ) ; } public static void Main ( ) { List < int > a = new List < int > ( ) { 1 , - 3 , 1 , 0 } ; minOperations ( a ) ; } }

Index/key variables: i
Accumulator variables: ans, i, r, sum
Iterator variables: i, r
Class/struct names: GFG
C# program:
using System ; public class GFG { static void print ( long [ ] a , long [ ] b ) { long minProd = 0 ; for ( int i = 0 ; i < a . Length ; ++ i ) { Console . Write ( a [ i ] + " ▁ " ) ; } Console . WriteLine ( ) ; for ( int i = 0 ; i < b . Length ; ++ i ) { Console . Write ( b [ i ] + " ▁ " ) ; minProd += a [ i ] * b [ i ] ; } Console . WriteLine ( ) ; Console . WriteLine ( minProd ) ; } static void reverse ( int left , int right , long [ ] arr ) { while ( left < right ) { long temp = arr [ left ] ; arr [ left ] = arr [ right ] ; arr [ right ] = temp ; ++ left ; -- right ; } } static void minimumProdArray ( long [ ] a , long [ ] b , int l ) { long total = 0 ; for ( int i = 0 ; i < a . Length ; ++ i ) { total += a [ i ] * b [ i ] ; } long min = Int32 . MaxValue ; int first = 0 ; int second = 0 ; for ( int i = 0 ; i < a . Length ; ++ i ) { int left = i - 1 ; int right = i + 1 ; long total1 = total ; while ( left >= 0 && right < a . Length ) { total1 -= a [ left ] * b [ left ] + a [ right ] * b [ right ] ; total1 += a [ left ] * b [ right ] + a [ right ] * b [ left ] ; if ( min >= total1 ) { min = total1 ; first = left ; second = right ; } -- left ; ++ right ; } } for ( int i = 0 ; i < a . Length ; ++ i ) { int left = i ; int right = i + 1 ; long total1 = total ; while ( left >= 0 && right < a . Length ) { total1 -= a [ left ] * b [ left ] + a [ right ] * b [ right ] ; total1 += a [ left ] * b [ right ] + a [ right ] * b [ left ] ; if ( min >= total1 ) { min = total1 ; first = left ; second = right ; } -- left ; ++ right ; } } if ( min < total ) { reverse ( first , second , a ) ; print ( a , b ) ; } else { print ( a , b ) ; } } public static void Main ( string [ ] args ) { int n = 4 ; long [ ] a = { 2 , 3 , 1 , 5 } ; long [ ] b = { 8 , 2 , 4 , 3 } ; minimumProdArray ( a , b , n ) ; } }

Index/key variables: i, left, right
Accumulator variables: minProd, total, total1
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static int MaxCollection ( string S , int P , int Q ) { char [ ] maxstr = ( P >= Q ? " ab " : " ba " ) . ToCharArray ( ) ; char [ ] minstr = ( P >= Q ? " ba " : " ab " ) . ToCharArray ( ) ; int maxp = Math . Max ( P , Q ) ; int minp = Math . Min ( P , Q ) ; int cost = 0 ; Stack stack1 = new Stack ( ) ; char [ ] s = S . ToCharArray ( ) ; foreach ( char ch in s ) { if ( stack1 . Count > 0 && ( ( char ) stack1 . Peek ( ) == maxstr [ 0 ] && ch == maxstr [ 1 ] ) ) { stack1 . Pop ( ) ; cost += maxp ; } else { stack1 . Push ( ch ) ; } } string sb = " " ; while ( stack1 . Count > 0 ) { sb = sb + stack1 . Peek ( ) ; stack1 . Pop ( ) ; } char [ ] chars = sb . ToCharArray ( ) ; Array . Reverse ( chars ) ; string remstr = new string ( chars ) ; foreach ( char ch in remstr . ToCharArray ( ) ) { if ( stack1 . Count > 0 && ( ( char ) stack1 . Peek ( ) == minstr [ 0 ] && ch == minstr [ 1 ] ) ) { stack1 . Pop ( ) ; cost += minp ; } else { stack1 . Push ( ch ) ; } } return cost ; } static void Main ( ) { string S = " cbbaabbaab " ; int P = 6 ; int Q = 4 ; Console . Write ( MaxCollection ( S , P , Q ) ) ; } }

Accumulator variables: cost
Iterator variables: ch
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } public class BinaryTree { Node root ; void fillSet ( Node root , HashSet < int > set , int hd ) { if ( root == null ) return ; fillSet ( root . left , set , hd - 1 ) ; set . Add ( hd ) ; fillSet ( root . right , set , hd + 1 ) ; } int verticalWidth ( Node root ) { HashSet < int > set = new HashSet < int > ( ) ; fillSet ( root , set , 0 ) ; return set . Count ; } public static void Main ( String [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 5 ) ; tree . root . right . right = new Node ( 8 ) ; tree . root . right . right . left = new Node ( 6 ) ; tree . root . right . right . right = new Node ( 7 ) ; Console . WriteLine ( tree . verticalWidth ( tree . root ) ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { static int calc ( int a , int b ) { return a * b + ( b - a ) ; } static int findMaximum ( List < int > arr , int N ) { arr . Sort ( ) ; int ans = - 1000000000 ; ans = Math . Max ( ans , calc ( arr [ 0 ] , arr [ 1 ] ) ) ; ans = Math . Max ( ans , calc ( arr [ N - 2 ] , arr [ N - 1 ] ) ) ; return ans ; } public static void Main ( ) { List < int > arr = new List < int > { 0 , - 47 , 12 } ; int N = ( int ) arr . Count ; Console . Write ( findMaximum ( arr , N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static int minKBitFlips ( int [ ] A , int K ) { Queue flip = new Queue ( ) ; int count = 0 ; for ( int i = 0 ; i < A . Length ; i ++ ) { if ( flip . Count > 0 && ( i - ( int ) flip . Peek ( ) >= K ) ) { flip . Dequeue ( ) ; } if ( A [ i ] % 2 == flip . Count % 2 ) { if ( i + K - 1 >= A . Length ) { return - 1 ; } count ++ ; } } return count ; } } static void ( ) { int [ ] A = { 0 , 1 , 0 } ; int K = 1 ; int ans = minKBitFlips ( A , K ) ; Console . WriteLine ( ans ) ; }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minKBitFlips ( int [ ] A , int K ) { int [ ] temp = new int [ A . Length ] ; int count = 0 ; int flip = 0 ; for ( int i = 0 ; i < A . Length ; ++ i ) { flip ^= temp [ i ] ; if ( A [ i ] == flip ) { count ++ ; if ( i + K > A . Length ) { return - 1 ; } flip ^= 1 ; if ( i + K < A . Length ) { temp [ i + K ] ^= 1 ; } } } return count ; } public static void Main ( String [ ] args ) { int [ ] A = { 0 , 1 , 0 } ; int K = 1 ; int ans = minKBitFlips ( A , K ) ; Console . Write ( ans ) ; } }

Index/key variables: i
Accumulator variables: count, flip
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static void findKthElement ( int N , int K ) { List < int > v = new List < int > ( ) ; for ( int i = 1 ; i <= N ; i ++ ) { if ( i % 2 == 0 ) { v . Add ( i ) ; } } for ( int i = 1 ; i <= N ; i ++ ) { if ( i % 2 != 0 ) { v . Add ( i ) ; } } Console . WriteLine ( v [ K - 1 ] ) ; } public static void Main ( String [ ] args ) { int N = 10 , K = 3 ; findKthElement ( N , K ) ; } }

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