dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static void rearrange ( int [ ] arr , int n ) { int j = 0 , temp ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < 0 ) { temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; j ++ ; } } } static void printArray ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } public static void Main ( ) { int [ ] arr = { - 1 , 2 , - 3 , 4 , 5 , 6 , - 7 , 8 , 9 } ; int n = arr . Length ; rearrange ( arr , n ) ; printArray ( arr , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int maxSum ( int [ , ] arr ) { int m = ( int ) arr . GetLength ( 0 ) ; int n = ( int ) arr . GetLength ( 1 ) - 1 ; int [ , ] dp = new int [ m + 1 , n + 2 ] ; memset ( arr , 0 , sizeof ( arr ) ) ; for ( int i = 0 ; i <= m ; i ++ ) { for ( int j = 0 ; j <= n + 1 ; j ++ ) { dp [ i , j ] = 0 ; } } for ( int i = 1 ; i < m ; ++ i ) dp [ i , 1 ] = arr [ i , 1 ] ; for ( int i = 1 ; i < n + 1 ; ++ i ) { for ( int j = 1 ; j < m ; ++ j ) { int mx = 0 ; for ( int k = 1 ; k < m ; ++ k ) { if ( k != j ) { if ( dp [ k , i - 1 ] > mx ) { mx = dp [ k , i - 1 ] ; } } } if ( mx != 0 && arr [ j , i ] != 0 ) { dp [ j , i ] = arr [ j , i ] + mx ; } } } int ans = - 1 ; for ( int i = 1 ; i <= m ; ++ i ) { if ( ( dp [ i , n ] ) != 0 ) ans = Math . Max ( ans , dp [ i , n ] ) ; } return ans ; } public static void Main ( String [ ] args ) { int [ , ] arr = { { 0 , 0 , 0 , 0 , 0 } , { 0 , 10 , 2 , 20 , 0 } , { 0 , 0 , 0 , 5 , 0 } , { 0 , 0 , 0 , 0 , 6 } , { 0 , 4 , 0 , 11 , 5 } , { 0 , 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 , 0 } } ; Console . WriteLine ( maxSum ( arr ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static void segregateElements ( int [ ] arr , int n ) { int [ ] temp = new int [ n ] ; int j = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] >= 0 ) temp [ j ++ ] = arr [ i ] ; if ( j == n j == 0 ) return ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] < 0 ) temp [ j ++ ] = arr [ i ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = temp [ i ] ; } public static void Main ( ) { int [ ] arr = { 1 , - 1 , - 3 , - 2 , 7 , 5 , 11 , 6 } ; int n = arr . Length ; segregateElements ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: i, n
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void rearrange ( int [ ] arr , int n ) { int temp ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( i % 2 == 0 && arr [ i ] > arr [ i + 1 ] ) { temp = arr [ i ] ; arr [ i ] = arr [ i + 1 ] ; arr [ i + 1 ] = temp ; } if ( i % 2 != 0 && arr [ i ] < arr [ i + 1 ] ) { temp = arr [ i ] ; arr [ i ] = arr [ i + 1 ] ; arr [ i + 1 ] = temp ; } } } static void printArray ( int [ ] arr , int size ) { for ( int i = 0 ; i < size ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; } public static void Main ( ) { int [ ] arr = { 6 , 4 , 2 , 1 , 8 , 3 } ; int n = arr . Length ; Console . WriteLine ( " Before ▁ rearranging : ▁ " ) ; printArray ( arr , n ) ; rearrange ( arr , n ) ; Console . WriteLine ( " After ▁ rearranging : ▁ " ) ; printArray ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int shortestDistance ( string S , int N ) { int minDis = S . Length ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { if ( S [ i ] == S [ j ] && ( j - i ) < minDis ) { minDis = j - i ; break ; } } } if ( minDis == S . Length ) return - 1 ; else return minDis - 1 ; } public static void Main ( String [ ] args ) { string S = " geeksforgeeks " ; int N = 13 ; Console . Write ( shortestDistance ( S , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void rearrange ( int [ ] a , int size ) { int positive = 0 , negative = 1 , temp ; while ( true ) { while ( positive < size && a [ positive ] >= 0 ) positive += 2 ; while ( negative < size && a [ negative ] <= 0 ) negative += 2 ; if ( positive < size && negative < size ) { temp = a [ positive ] ; a [ positive ] = a [ negative ] ; a [ negative ] = temp ; } else break ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , - 3 , 5 , 6 , - 3 , 6 , 7 , - 4 , 9 , 10 } ; int n = arr . Length ; rearrange ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: i, negative, positive
Accumulator variables: i, negative, positive
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void possibleNumbers ( int N , int M , int A , int B ) { if ( A > B ) { int temp = A ; A = B ; B = temp ; } int number = N + M * A ; Console . Write ( number + " ▁ " ) ; if ( A != B ) { for ( int i = 0 ; i < M ; i ++ ) { number = number - A + B ; Console . Write ( number + " ▁ " ) ; } } } public static void Main ( String [ ] args ) { int N = 5 , M = 3 , A = 4 , B = 6 ; possibleNumbers ( N , M , A , B ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void swap ( int [ ] a , int i , int j ) { int temp = a [ i ] ; a [ i ] = a [ j ] ; a [ j ] = temp ; } static void printArray ( int [ ] a , int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( a [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; } public static void Main ( ) { int [ ] arr = { 1 , - 3 , 5 , 6 , - 3 , 6 , 7 , - 4 , 9 , 10 } ; int n = arr . Length ; printArray ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] >= 0 && i % 2 == 1 ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( arr [ j ] < 0 && j % 2 == 0 ) { swap ( arr , i , j ) ; break ; } } } else if ( arr [ i ] < 0 && i % 2 == 0 ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( arr [ j ] >= 0 && j % 2 == 1 ) { swap ( arr , i , j ) ; break ; } } } } printArray ( arr , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void arrayEvenAndOdd ( int [ ] arr , int n ) { int i = - 1 , j = 0 ; while ( j != n ) { if ( arr [ j ] % 2 == 0 ) { i ++ ; int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; } j ++ ; } for ( int k = 0 ; k < n ; k ++ ) Console . Write ( arr [ k ] + " ▁ " ) ; } static void Main ( ) { int [ ] arr = { 1 , 3 , 2 , 4 , 7 , 6 , 9 , 10 } ; int n = arr . Length ; arrayEvenAndOdd ( arr , n ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: k
Class/struct names: GFG
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 Sum { public int sum = 0 ; } public class BinaryTree { public Node root ; public virtual void leftLeavesSumRec ( Node node , bool isleft , Sum summ ) { if ( node == null ) { return ; } if ( node . left == null && node . right == null && isleft ) { summ . sum = summ . sum + node . data ; } leftLeavesSumRec ( node . left , true , summ ) ; leftLeavesSumRec ( node . right , false , summ ) ; } public virtual int leftLeavesSum ( Node node ) { Sum suum = new Sum ( ) ; leftLeavesSumRec ( node , false , suum ) ; return suum . sum ; } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 20 ) ; tree . root . left = new Node ( 9 ) ; tree . root . right = new Node ( 49 ) ; tree . root . left . right = new Node ( 12 ) ; tree . root . left . left = new Node ( 5 ) ; tree . root . right . left = new Node ( 23 ) ; tree . root . right . right = new Node ( 52 ) ; tree . root . left . right . right = new Node ( 12 ) ; tree . root . right . right . left = new Node ( 50 ) ; Console . WriteLine ( " The ▁ sum ▁ of ▁ leaves ▁ is ▁ " + tree . leftLeavesSum ( tree . root ) ) ; } }

Class/struct names: BinaryTree, Node, Sum
C# program:
using System ; class Node { public int key ; public Node left , right ; public Node ( int item ) { key = item ; left = right = null ; } } class GFG { Node root ; Boolean isMirror ( Node node1 , Node node2 ) { if ( node1 == null && node2 == null ) return true ; if ( node1 != null && node2 != null && node1 . key == node2 . key ) return ( isMirror ( node1 . left , node2 . right ) && isMirror ( node1 . right , node2 . left ) ) ; return false ; } Boolean isSymmetric ( ) { return isMirror ( root , root ) ; } static public void Main ( String [ ] args ) { GFG tree = new GFG ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 2 ) ; tree . root . left . left = new Node ( 3 ) ; tree . root . left . right = new Node ( 4 ) ; tree . root . right . left = new Node ( 4 ) ; tree . root . right . right = new Node ( 3 ) ; Boolean output = tree . isSymmetric ( ) ; if ( output == true ) Console . WriteLine ( " Symmetric " ) ; else Console . WriteLine ( " Not ▁ symmetric " ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; class GFG { static void minimumCost ( string str , int L , int U ) { int N = str . Length ; char [ ] s = str . ToCharArray ( ) ; string ans = " " ; int [ ] lowerFreq = new int [ 26 ] ; int [ ] upperFreq = new int [ 26 ] ; for ( int i = 0 ; i < N ; i ++ ) { if ( char . IsUpper ( s [ i ] ) ) upperFreq [ s [ i ] - ' A ' ] ++ ; else lowerFreq [ s [ i ] - ' a ' ] ++ ; } int [ ] result = new int [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( lowerFreq [ i ] != 0 upperFreq [ i ] != 0 ) { int costToUpper = U * lowerFreq [ i ] ; int costToLower = L * upperFreq [ i ] ; if ( costToLower < costToUpper ) { result [ i ] = 1 ; } } } for ( int i = 0 ; i < N ; i ++ ) { int index = 0 ; if ( char . IsLower ( s [ i ] ) ) index = s [ i ] - ' a ' ; else index = s [ i ] - ' A ' ; if ( result [ index ] == 1 ) { s [ i ] = char . ToLower ( s [ i ] ) ; } else { s [ i ] = char . ToUpper ( s [ i ] ) ; } } Console . WriteLine ( new string ( s ) ) ; } public static void Main ( string [ ] args ) { string S = " aabbAA " ; int L = 1 , U = 1 ; minimumCost ( S , L , U ) ; } }

Index/key variables: i, index
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int Check ( int [ , ] A , int [ , ] B , int M , int N , int X ) { for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j <= N - X ; j ++ ) { if ( A [ i , j ] != B [ i , j ] ) { int diff = B [ i , j ] - A [ i , j ] ; for ( int k = 0 ; k < X ; k ++ ) { A [ i , j + k ] = A [ i , j + k ] + diff ; } } } } for ( int i = 0 ; i <= M - X ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( A [ i , j ] != B [ i , j ] ) { int diff = B [ i , j ] - A [ i , j ] ; for ( int k = 0 ; k < X ; k ++ ) { A [ i + k , j ] = A [ i + k , j ] + diff ; } } } } for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( A [ i , j ] != B [ i , j ] ) { return 0 ; } } } return 1 ; } public static void Main ( ) { int M = 2 , N = 2 , X = 2 ; int [ , ] A = { { 0 , 0 } , { 0 , 0 } } ; int [ , ] B = { { 1 , 2 } , { 0 , 1 } } ; if ( Check ( A , B , M , N , X ) == 1 ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }

Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { class HeapNode { public int val ; public int r ; public int c ; public HeapNode ( int val , int r , int c ) { this . val = val ; this . c = c ; this . r = r ; } } static void swap ( int i , int min , HeapNode [ ] arr ) { HeapNode temp = arr [ i ] ; arr [ i ] = arr [ min ] ; arr [ min ] = temp ; } static void minHeapify ( HeapNode [ ] harr , int i , int heap_size ) { int l = 2 * i + 1 ; int r = 2 * i + 2 ; int min = i ; if ( l < heap_size && harr [ l ] . val < harr [ i ] . val ) { min = l ; } if ( r < heap_size && harr [ r ] . val = 0 ) { minHeapify ( harr , i , n ) ; i -- ; } } public static int kthSmallest ( int [ , ] mat , int n , int k ) { if ( k n * n ) { return int . MaxValue ; } HeapNode [ ] harr = new HeapNode [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { harr [ i ] = new HeapNode ( mat [ 0 , i ] , 0 , i ) ; } buildHeap ( harr , n ) ; HeapNode hr = new HeapNode ( 0 , 0 , 0 ) ; for ( int i = 1 ; i < k ; i ++ ) { hr = harr [ 0 ] ; int nextVal = hr . r < n - 1 ? mat [ hr . r + 1 , hr . c ] : int . MaxValue ; harr [ 0 ] = new HeapNode ( nextVal , hr . r + 1 , hr . c ) ; minHeapify ( harr , 0 , n ) ; } return hr . val ; } public static void Main ( String [ ] args ) { int [ , ] mat = { { 10 , 20 , 30 , 40 } , { 15 , 25 , 35 , 45 } , { 25 , 29 , 37 , 48 } , { 32 , 33 , 39 , 50 } } ; int res = kthSmallest ( mat , 4 , 7 ) ; Console . Write ( "7th ▁ smallest ▁ element ▁ is ▁ " + res ) ; } }

Index/key variables: i, l, min, n, r
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, HeapNode
C# program:
using System ; using System . Collections . Generic ; class GFG { static void minOperations ( int [ ] arr , int N ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int res = arr [ i ] ; while ( res > 0 ) { if ( mp . ContainsKey ( res ) ) { mp [ res ] ++ ; } else { mp [ res ] = 1 ; } res /= 2 ; } } int mx = 1 ; foreach ( KeyValuePair < int , int > it in mp ) { if ( it . Value == N ) { mx = it . Key ; } } int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int res = arr [ i ] ; while ( res != mx ) { ans ++ ; res /= 2 ; } } Console . Write ( ans ) ; } static void Main ( ) { int [ ] arr = { 3 , 1 , 1 , 3 } ; int N = arr . Length ; minOperations ( arr , N ) ; } }

Index/key variables: i, res
Accumulator variables: ans, i, res
Iterator variables: i, it
Class/struct names: GFG
C# program:
using System ; class GFG { static char Winner ( int N ) { bool player = true ; while ( N > 1 ) { int den = ( player ) ? 9 : 2 ; int X = N / den ; int Y = N % den ; N = ( Y > 0 ) ? X + 1 : X ; player = ! player ; } if ( player ) return ' B ' ; else return ' A ' ; } static public void Main ( ) { int N = 10 ; Console . WriteLine ( Winner ( N ) ) ; } }

Boolean variables: player
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] arr = { 10 , 324 , 45 , 90 , 9808 } ; static int largest ( ) { int i ; int max = arr [ 0 ] ; for ( i = 1 ; i < arr . Length ; i ++ ) if ( arr [ i ] > max ) max = arr [ i ] ; return max ; } public static void Main ( ) { Console . WriteLine ( " Largest ▁ in ▁ given ▁ " + " array ▁ is ▁ " + largest ( ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void minimumsteps ( int N ) { int steps = 0 ; while ( steps * ( steps + 1 ) < 2 * N ) { steps ++ ; } if ( steps * ( steps + 1 ) / 2 == N + 1 ) { steps ++ ; } Console . WriteLine ( steps ) ; } static public void Main ( ) { int N = 18 ; minimumsteps ( N ) ; } }

Accumulator variables: steps
Class/struct names: GFG
C# program:
using System ; using System . Linq ; public class GFG { static int largest ( int [ ] arr , int n ) { return arr . Max ( ) ; } static public void Main ( ) { int [ ] arr = { 10 , 324 , 45 , 90 , 9808 } ; int n = arr . Length ; Console . WriteLine ( largest ( arr , n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { void find3largest ( int [ ] arr ) { Array . Sort ( arr ) ; int n = arr . Length ; int check = 0 , count = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( count < 4 ) { if ( check != arr [ n - i ] ) { Console . Write ( arr [ n - i ] + " ▁ " ) ; check = arr [ n - i ] ; count ++ ; } } else break ; } } public static void Main ( ) { GFG obj = new GFG ( ) ; int [ ] arr = { 12 , 45 , 1 , - 1 , 45 , 54 , 23 , 5 , 0 , - 10 } ; obj . find3largest ( arr ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int minCntCharDeletionsfrequency ( char [ ] str , int N ) { Dictionary < char , int > mp = new Dictionary < char , int > ( ) ; List < int > pq = new List < int > ( ) ; int cntChar = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( mp . ContainsKey ( str [ i ] ) ) { mp [ str [ i ] ] ++ ; } else { mp . Add ( str [ i ] , 1 ) ; } } foreach ( KeyValuePair < char , int > it in mp ) { pq . Add ( it . Value ) ; } pq . Sort ( ) ; pq . Reverse ( ) ; while ( pq . Count != 0 ) { pq . Sort ( ) ; pq . Reverse ( ) ; int frequent = pq [ 0 ] ; pq . RemoveAt ( 0 ) ; if ( pq . Count == 0 ) { return cntChar ; } if ( frequent == pq [ 0 ] ) { if ( frequent > 1 ) { pq . Add ( frequent - 1 ) ; pq . Sort ( ) ; pq . Reverse ( ) ; } cntChar ++ ; } } return cntChar ; } public static void Main ( String [ ] args ) { String str = " abbbcccd " ; int N = str . Length ; Console . Write ( minCntCharDeletionsfrequency ( str . ToCharArray ( ) , N ) ) ; } }

Index/key variables: i
Accumulator variables: cntChar, i
Iterator variables: i, it
Class/struct names: GFG
C# program:
using System ; class GFG { public static bool issafe ( char [ , ] v , int i , int j , int n , int m , char ch ) { int [ ] rowN = { 1 , - 1 , 0 , 0 } ; int [ ] colN = { 0 , 0 , 1 , - 1 } ; for ( int k = 0 ; k < 4 ; k ++ ) { if ( i + rowN [ k ] >= 0 && i + rowN [ k ] < n && j + colN [ k ] >= 0 && j + colN [ k ] < m && v [ ( i + rowN [ k ] ) , ( j + colN [ k ] ) ] == ch ) { return false ; } } return true ; } public static bool place ( char [ , ] v , int n , int m ) { int i = 0 , j = 0 ; for ( i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < m ; j ++ ) { if ( v [ i , j ] == ' F ' ) { break ; } } if ( j != m ) { break ; } } if ( i == n && j == m ) { return true ; } if ( issafe ( v , i , j , n , m , '1' ) ) { v [ i , j ] = '1' ; if ( place ( v , n , m ) ) { return true ; } v [ i , j ] = ' F ' ; } if ( issafe ( v , i , j , n , m , '2' ) ) { v [ i , j ] = '2' ; if ( place ( v , n , m ) ) { return true ; } v [ i , j ] = ' F ' ; } return false ; } public static void printMatrix ( char [ , ] arr , int n , int m ) { place ( arr , n , m ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { Console . Write ( arr [ i , j ] ) ; } Console . WriteLine ( ) ; } } public static void Main ( ) { char [ , ] arr = { { ' F ' , ' F ' , ' F ' , ' F ' } , { ' F ' , ' O ' , ' F ' , ' F ' } , { ' F ' , ' F ' , ' O ' , ' F ' } , { ' F ' , ' F ' , ' F ' , ' F ' } , } ; int n = 4 , m = 4 ; printMatrix ( arr , n , m ) ; } }

Index/key variables: k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { public static double findMean ( int [ ] a , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += a [ i ] ; return ( double ) sum / ( double ) n ; } public static double findMedian ( int [ ] a , int n ) { Array . Sort ( a ) ; if ( n % 2 != 0 ) return ( double ) a [ n / 2 ] ; return ( double ) ( a [ ( n - 1 ) / 2 ] + a [ n / 2 ] ) / 2.0 ; } public static void Main ( ) { int [ ] a = { 1 , 3 , 4 , 2 , 7 , 5 , 8 , 6 } ; int n = a . Length ; Console . Write ( " Mean ▁ = ▁ " + findMean ( a , n ) + " STRNEWLINE " ) ; Console . Write ( " Median ▁ = ▁ " + findMedian ( a , n ) + " STRNEWLINE " ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public class Node { public int key ; public Node left , right ; public Node ( int key_ ) { this . key = key_ ; this . left = null ; this . right = null ; } } ; static int sumOfLeftLeaves ( Node root ) { if ( root == null ) return 0 ; Stack < Node > stack_ = new Stack < Node > ( ) ; stack_ . Push ( root ) ; int sum = 0 ; while ( stack_ . Count > 0 ) { Node currentNode = stack_ . Peek ( ) ; stack_ . Pop ( ) ; if ( currentNode . left != null ) { stack_ . Push ( currentNode . left ) ; if ( currentNode . left . left == null && currentNode . left . right == null ) { sum = sum + currentNode . left . key ; } } if ( currentNode . right != null ) stack_ . Push ( currentNode . right ) ; } return sum ; } public static void Main ( String [ ] args ) { Node root = new Node ( 20 ) ; root . left = new Node ( 9 ) ; root . right = new Node ( 49 ) ; root . right . left = new Node ( 23 ) ; root . right . right = new Node ( 52 ) ; root . right . right . left = new Node ( 50 ) ; root . left . left = new Node ( 5 ) ; root . left . right = new Node ( 12 ) ; root . left . right . right = new Node ( 12 ) ; Console . Write ( " Sum ▁ of ▁ left ▁ leaves ▁ is ▁ " + sumOfLeftLeaves ( root ) + " STRNEWLINE " ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; class GFG { static void findXandYwithminABSX_Y ( int N ) { if ( N % 2 == 1 ) { Console . Write ( ( N / 2 ) + " ▁ " + ( N / 2 + 1 ) ) ; } else { Console . Write ( ( N / 2 - 1 ) + " ▁ " + ( N / 2 + 1 ) ) ; } } public static void Main ( ) { int N = 12 ; findXandYwithminABSX_Y ( N ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int findMax ( int [ ] a , int [ , ] dp , int i , int flag ) { if ( i == ( int ) a . Length ) { return 0 ; } if ( dp [ i , flag ] != - 1 ) { return dp [ i , flag ] ; } int ans ; if ( flag == 0 ) { ans = Math . Max ( findMax ( a , dp , i + 1 , 0 ) , a [ i ] + findMax ( a , dp , i + 1 , 1 ) ) ; } else { ans = Math . Max ( findMax ( a , dp , i + 1 , 1 ) , - 1 * a [ i ] + findMax ( a , dp , i + 1 , 0 ) ) ; } return dp [ i , flag ] = ans ; } static void findMaxSumUtil ( int [ ] arr , int N ) { int [ , ] dp = new int [ N , 2 ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { dp [ i , j ] = - 1 ; } } Console . WriteLine ( findMax ( arr , dp , 0 , 0 ) ) ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 1 , 2 } ; int N = arr . Length ; findMaxSumUtil ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void findWinner ( char [ ] s ) { int vowels_count = 0 , consonants_count = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( s [ i ] == ' a ' s [ i ] == ' e ' s [ i ] == ' i ' s [ i ] == ' o ' s [ i ] == ' u ' ) { vowels_count ++ ; } else { consonants_count ++ ; } } if ( vowels_count == 0 ) { if ( consonants_count % 2 == 0 ) { Console . Write ( " Player ▁ B " ) ; } else { Console . Write ( " Player ▁ A " ) ; } } else if ( vowels_count == 1 && consonants_count % 2 != 0 ) { Console . Write ( " Player ▁ A " ) ; } else { Console . Write ( " D " ) ; } } public static void Main ( String [ ] args ) { String s = " abcd " ; findWinner ( s . ToCharArray ( ) ) ; } }

Index/key variables: i
Accumulator variables: consonants_count, i, vowels_count
Iterator variables: i
Class/struct names: GFG
C# program:
using System . Collections . Generic ; using System ; class GFG { static void getSmallestArray ( int A , int B ) { List < int > arr = new List < int > ( ) ; for ( int i = 0 ; i < A ; i ++ ) arr . Add ( i + 1 ) ; List < int > ans = new List < int > ( ) ; for ( int i = 0 ; i < B - 1 ; i ++ ) ans . Add ( arr [ i ] ) ; ans . Add ( arr [ A - 1 ] ) ; for ( int i = B ; i < A ; i ++ ) ans . Add ( arr [ i - 1 ] ) ; for ( int i = 0 ; i < A ; i ++ ) Console . Write ( ans [ i ] + " ▁ " ) ; } public static void Main ( ) { int A = 3 ; int B = 2 ; getSmallestArray ( A , B ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GfG { public static void printSmall ( int [ ] arr , int n , int k ) { for ( int i = k ; i < n ; ++ i ) { int max_var = arr [ k - 1 ] ; int pos = k - 1 ; for ( int j = k - 2 ; j >= 0 ; j -- ) { if ( arr [ j ] > max_var ) { max_var = arr [ j ] ; pos = j ; } } if ( max_var > arr [ i ] ) { int j = pos ; while ( j < k - 1 ) { arr [ j ] = arr [ j + 1 ] ; j ++ ; } arr [ k - 1 ] = arr [ i ] ; } } for ( int i = 0 ; i < k ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } public static void Main ( ) { int [ ] arr = { 1 , 5 , 8 , 9 , 6 , 7 , 3 , 4 , 2 , 0 } ; int n = 10 ; int k = 5 ; printSmall ( arr , n , k ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GfG