dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int binarySearch ( int [ ] inorder , int l , int r , int d ) { int mid = ( l + r ) >> 1 ; if ( inorder [ mid ] == d ) return mid ; else if ( inorder [ mid ] > d ) return binarySearch ( inorder , l , mid - 1 , d ) ; else return binarySearch ( inorder , mid + 1 , r , d ) ; } static int ind ; static void leafNodesRec ( int [ ] preorder , int [ ] inorder , int l , int r , int n ) { if ( l == r ) { Console . Write ( " { 0 } ▁ " , inorder [ l ] ) ; ind = ind + 1 ; return ; } if ( l < 0 l > r r >= n ) return ; int loc = binarySearch ( inorder , l , r , preorder [ ind ] ) ; ind = ind + 1 ; leafNodesRec ( preorder , inorder , l , loc - 1 , n ) ; leafNodesRec ( preorder , inorder , loc + 1 , r , n ) ; } static void leafNodes ( int [ ] preorder , int n ) { int [ ] inorder = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) inorder [ i ] = preorder [ i ] ; Array . Sort ( inorder ) ; leafNodesRec ( preorder , inorder , 0 , n - 1 , n ) ; } public static void Main ( String [ ] args ) { int [ ] preorder = { 890 , 325 , 290 , 530 , 965 } ; int n = preorder . Length ; leafNodes ( preorder , n ) ; } }

Index/key variables: i, ind, l, mid, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GfG { public static void leafNode ( int [ ] preorder , int n ) { Stack < int > s = new Stack < int > ( ) ; for ( int i = 0 , j = 1 ; j < n ; i ++ , j ++ ) { bool found = false ; if ( preorder [ i ] > preorder [ j ] ) { s . Push ( preorder [ i ] ) ; } else { while ( s . Count > 0 ) { if ( preorder [ j ] > s . Peek ( ) ) { s . Pop ( ) ; found = true ; } else { break ; } } } if ( found ) { Console . Write ( preorder [ i ] + " ▁ " ) ; } } Console . WriteLine ( preorder [ n - 1 ] ) ; } public static void Main ( string [ ] args ) { int [ ] preorder = new int [ ] { 890 , 325 , 290 , 530 , 965 } ; int n = preorder . Length ; leafNode ( preorder , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Boolean variables: found
Class/struct names: GfG
C# program:
using System ; class GFG { static int i = 0 ; static bool isLeaf ( int [ ] pre , int n , int min , int max ) { if ( i >= n ) { return false ; } if ( pre [ i ] > min && pre [ i ] < max ) { i ++ ; bool left = isLeaf ( pre , n , min , pre [ i - 1 ] ) ; bool right = isLeaf ( pre , n , pre [ i - 1 ] , max ) ; if ( ! left && ! right ) { Console . Write ( pre [ i - 1 ] + " ▁ " ) ; } return true ; } return false ; } static void printLeaves ( int [ ] preorder , int n ) { isLeaf ( preorder , n , int . MinValue , int . MaxValue ) ; } public static void Main ( String [ ] args ) { int [ ] preorder = { 890 , 325 , 290 , 530 , 965 } ; int n = preorder . Length ; printLeaves ( preorder , n ) ; } }

Index/key variables: i
Accumulator variables: i
Class/struct names: GFG
C# program:
using System ; class GfG { class Node { public int key ; public Node left , right , parent ; } static Node newNode ( int item ) { Node temp = new Node ( ) ; temp . key = item ; temp . left = null ; temp . right = null ; temp . parent = null ; return temp ; } static void inorder ( Node root ) { if ( root != null ) { inorder ( root . left ) ; Console . Write ( " Node ▁ : ▁ " + root . key + " ▁ , ▁ " ) ; if ( root . parent == null ) Console . WriteLine ( " Parent ▁ : ▁ NULL " ) ; else Console . WriteLine ( " Parent ▁ : ▁ " + root . parent . key ) ; inorder ( root . right ) ; } } static Node insert ( Node node , int key ) { if ( node == null ) return newNode ( key ) ; if ( key < node . key ) { Node lchild = insert ( node . left , key ) ; node . left = lchild ; lchild . parent = node ; } else if ( key > node . key ) { Node rchild = insert ( node . right , key ) ; node . right = rchild ; rchild . parent = node ; } return node ; } public static void Main ( String [ ] args ) { Node root = null ; root = insert ( root , 50 ) ; insert ( root , 30 ) ; insert ( root , 20 ) ; insert ( root , 40 ) ; insert ( root , 70 ) ; insert ( root , 60 ) ; insert ( root , 80 ) ; inorder ( root ) ; } }

Class/struct names: GfG, Node
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 Index { public int index = 0 ; } class GFG { public Node root ; public Index myindex = new Index ( ) ; public virtual Node constructTreeUtil ( int [ ] pre , char [ ] preLN , Index index_ptr , int n , Node temp ) { int index = index_ptr . index ; if ( index == n ) { return null ; } temp = new Node ( pre [ index ] ) ; ( index_ptr . index ) ++ ; if ( preLN [ index ] == ' N ' ) { temp . left = constructTreeUtil ( pre , preLN , index_ptr , n , temp . left ) ; temp . right = constructTreeUtil ( pre , preLN , index_ptr , n , temp . right ) ; } return temp ; } public virtual Node constructTree ( int [ ] pre , char [ ] preLN , int n , Node node ) { int index = 0 ; return constructTreeUtil ( pre , preLN , myindex , n , node ) ; } public virtual void printInorder ( Node node ) { if ( node == null ) { return ; } printInorder ( node . left ) ; Console . Write ( node . data + " ▁ " ) ; printInorder ( node . right ) ; } public static void Main ( string [ ] args ) { GFG tree = new GFG ( ) ; int [ ] pre = new int [ ] { 10 , 30 , 20 , 5 , 15 } ; char [ ] preLN = new char [ ] { ' N ' , ' N ' , ' L ' , ' L ' , ' L ' } ; int n = pre . Length ; Node mynode = tree . constructTree ( pre , preLN , n , tree . root ) ; Console . WriteLine ( " Following ▁ is ▁ Inorder ▁ Traversal ▁ of ▁ the " + " Constructed ▁ Binary ▁ Tree : ▁ " ) ; tree . printInorder ( mynode ) ; } }

Index/key variables: index
Class/struct names: GFG, Index, Node
C# program:
using System ; class GFG { static void pairs ( int [ ] arr , int n , int k ) { int smallest = 0 ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) { if ( Math . Abs ( arr [ i ] + arr [ j ] - k ) < smallest ) { smallest = Math . Abs ( arr [ i ] + arr [ j ] - k ) ; count = 1 ; } else if ( Math . Abs ( arr [ i ] + arr [ j ] - k ) == smallest ) count ++ ; } Console . WriteLine ( " Minimal ▁ Value ▁ = ▁ " + smallest ) ; Console . WriteLine ( " Total ▁ Pairs ▁ = ▁ " + count ) ; } public static void Main ( ) { int [ ] arr = { 3 , 5 , 7 , 5 , 1 , 9 , 9 } ; int k = 12 ; int n = arr . Length ; pairs ( arr , n , k ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public class Node { public int data ; public Node left , right ; public int leftSize ; } static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . data = data ; temp . left = null ; temp . right = null ; temp . leftSize = 0 ; return temp ; } static Node insert ( Node root , int data ) { if ( root == null ) return newNode ( data ) ; if ( data <= root . data ) { root . left = insert ( root . left , data ) ; root . leftSize ++ ; } else root . right = insert ( root . right , data ) ; return root ; } static int getRank ( Node root , int x ) { if ( root . data == x ) return root . leftSize ; if ( x < root . data ) { if ( root . left == null ) return - 1 ; else return getRank ( root . left , x ) ; } else { if ( root . right == null ) return - 1 ; else { int rightSize = getRank ( root . right , x ) ; if ( rightSize == - 1 ) return - 1 ; return root . leftSize + 1 + rightSize ; } } } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 1 , 4 , 4 , 5 , 9 , 7 , 13 , 3 } ; int n = arr . Length ; int x = 4 ; Node root = null ; for ( int i = 0 ; i < n ; i ++ ) root = insert ( root , arr [ i ] ) ; Console . WriteLine ( " Rank ▁ of ▁ " + x + " ▁ in ▁ stream ▁ is ▁ : ▁ " + getRank ( root , x ) ) ; x = 13 ; Console . WriteLine ( " Rank ▁ of ▁ " + x + " ▁ in ▁ stream ▁ is ▁ : ▁ " + getRank ( root , x ) ) ; } }

Index/key variables: i
Accumulator variables: i, leftSize
Iterator variables: i
Class/struct names: GFG, Node
C# program:
using System ; class GFG { public static void Main ( ) { int [ ] a = { 5 , 1 , 14 , 4 , 15 , 9 , 7 , 20 , 11 } ; int key = 20 ; int arraySize = a . Length ; int count = 0 ; for ( int i = 0 ; i < arraySize ; i ++ ) { if ( a [ i ] <= key ) { count += 1 ; } } Console . WriteLine ( " Rank ▁ of ▁ " + key + " ▁ in ▁ stream ▁ is : ▁ " + ( count - 1 ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class Node { public int info ; public Node left , right ; public Node ( int d ) { info = d ; left = right = null ; } } public class BinaryTree { public static Node head ; public static int count ; public Node insert ( Node node , int info ) { if ( node == null ) { return ( new Node ( info ) ) ; } else { if ( info <= node . info ) { node . left = insert ( node . left , info ) ; } else { node . right = insert ( node . right , info ) ; } } return node ; } static int check ( int num ) { int sum = 0 , i = num , sum_of_digits , prod_of_digits ; if ( num < 10 num > 99 ) { return 0 ; } else { sum_of_digits = ( i % 10 ) + ( i / 10 ) ; prod_of_digits = ( i % 10 ) * ( i / 10 ) ; sum = sum_of_digits + prod_of_digits ; } if ( sum == num ) { return 1 ; } else { return 0 ; } } static void countSpecialDigit ( Node rt ) { int x ; if ( rt == null ) { return ; } else { x = check ( rt . info ) ; if ( x == 1 ) { count = count + 1 ; } countSpecialDigit ( rt . left ) ; countSpecialDigit ( rt . right ) ; } } static public void Main ( ) { BinaryTree tree = new BinaryTree ( ) ; Node root = null ; root = tree . insert ( root , 50 ) ; tree . insert ( root , 29 ) ; tree . insert ( root , 59 ) ; tree . insert ( root , 19 ) ; tree . insert ( root , 53 ) ; tree . insert ( root , 556 ) ; tree . insert ( root , 56 ) ; tree . insert ( root , 94 ) ; tree . insert ( root , 13 ) ; countSpecialDigit ( root ) ; Console . WriteLine ( count ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } class GFG { public Node root ; public virtual Node buildTree ( int [ ] inorder , int start , int end , Node node ) { if ( start > end ) { return null ; } int i = max ( inorder , start , end ) ; node = new Node ( inorder [ i ] ) ; if ( start == end ) { return node ; } node . left = buildTree ( inorder , start , i - 1 , node . left ) ; node . right = buildTree ( inorder , i + 1 , end , node . right ) ; return node ; } public virtual int max ( int [ ] arr , int strt , int end ) { int i , max = arr [ strt ] , maxind = strt ; for ( i = strt + 1 ; i <= end ; i ++ ) { if ( arr [ i ] > max ) { max = arr [ i ] ; maxind = i ; } } return maxind ; } public virtual void printInorder ( Node node ) { if ( node == null ) { return ; } printInorder ( node . left ) ; Console . Write ( node . data + " ▁ " ) ; printInorder ( node . right ) ; } public static void Main ( string [ ] args ) { GFG tree = new GFG ( ) ; int [ ] inorder = new int [ ] { 5 , 10 , 40 , 30 , 28 } ; int len = inorder . Length ; Node mynode = tree . buildTree ( inorder , 0 , len - 1 , tree . root ) ; Console . WriteLine ( " Inorder ▁ traversal ▁ of ▁ " + " the ▁ constructed ▁ tree ▁ is ▁ " ) ; tree . printInorder ( mynode ) ; } }

Index/key variables: i, strt
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Node
C# program:
using System ; class solution { class Node { public int data ; public Node left , right ; } ; static Node newNode ( int data ) { Node node = new Node ( ) ; node . data = data ; node . left = node . right = null ; return ( node ) ; } static Boolean treeContinuous ( Node ptr ) { if ( ptr == null ) return true ; if ( ptr . left == null && ptr . right == null ) return true ; if ( ptr . left == null ) return ( Math . Abs ( ptr . data - ptr . right . data ) == 1 ) && treeContinuous ( ptr . right ) ; if ( ptr . right == null ) return ( Math . Abs ( ptr . data - ptr . left . data ) == 1 ) && treeContinuous ( ptr . left ) ; return Math . Abs ( ptr . data - ptr . left . data ) == 1 && Math . Abs ( ptr . data - ptr . right . data ) == 1 && treeContinuous ( ptr . left ) && treeContinuous ( ptr . right ) ; } static public void Main ( String [ ] args ) { Node root = newNode ( 3 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 4 ) ; root . left . left = newNode ( 1 ) ; root . left . right = newNode ( 3 ) ; root . right . right = newNode ( 5 ) ; if ( treeContinuous ( root ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Class/struct names: Node, solution
C# program:
using System ; class GFG { static int MAX = 100 ; static void middlesum ( int [ , ] mat , int n ) { int row_sum = 0 , col_sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) row_sum += mat [ n / 2 , i ] ; Console . WriteLine ( " Sum ▁ of ▁ middle ▁ row ▁ = ▁ " + row_sum ) ; for ( int i = 0 ; i < n ; i ++ ) col_sum += mat [ i , n / 2 ] ; Console . WriteLine ( " Sum ▁ of ▁ middle ▁ column ▁ = ▁ " + col_sum ) ; } public static void Main ( ) { int [ , ] mat = { { 2 , 5 , 7 } , { 3 , 7 , 2 } , { 5 , 6 , 9 } } ; middlesum ( mat , 3 ) ; } }

Accumulator variables: col_sum, i, row_sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int M = 3 ; static int N = 3 ; static void rotateMatrix ( int [ , ] matrix , int k ) { int [ ] temp = new int [ M ] ; k = k % M ; for ( int i = 0 ; i < N ; i ++ ) { for ( int t = 0 ; t < M - k ; t ++ ) temp [ t ] = matrix [ i , t ] ; for ( int j = M - k ; j < M ; j ++ ) matrix [ i , j - M + k ] = matrix [ i , j ] ; for ( int j = k ; j < M ; j ++ ) matrix [ i , j ] = temp [ j - k ] ; } } static void displayMatrix ( int [ , ] matrix ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) Console . Write ( matrix [ i , j ] + " ▁ " ) ; Console . WriteLine ( ) ; } } public static void Main ( ) { int [ , ] matrix = { { 12 , 23 , 34 } , { 45 , 56 , 67 } , { 78 , 89 , 91 } } ; int k = 2 ; rotateMatrix ( matrix , k ) ; displayMatrix ( matrix ) ; } }

Index/key variables: M, t
Accumulator variables: i, j, t
Iterator variables: i, j, t
Class/struct names: GFG
C# program:
using System ; class GFG { static int N = 3 ; static void multiply ( int [ , ] mat , int [ , ] res ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { res [ i , j ] = 0 ; for ( int k = 0 ; k < N ; k ++ ) res [ i , j ] += mat [ i , k ] * mat [ k , j ] ; } } } static bool InvolutoryMatrix ( int [ , ] mat ) { int [ , ] res = new int [ N , N ] ; multiply ( mat , res ) ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( i == j && res [ i , j ] != 1 ) return false ; if ( i != j && res [ i , j ] != 0 ) return false ; } } return true ; } public static void Main ( ) { int [ , ] mat = { { 1 , 0 , 0 } , { 0 , - 1 , 0 } , { 0 , 0 , - 1 } } ; if ( InvolutoryMatrix ( mat ) ) Console . WriteLine ( " Involutory ▁ Matrix " ) ; else Console . WriteLine ( " Not ▁ Involutory ▁ Matrix " ) ; } }

Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { public static void interchangeFirstLast ( int [ ] [ ] m ) { int rows = m . Length ; for ( int i = 0 ; i < m [ 0 ] . Length ; i ++ ) { int t = m [ 0 ] [ i ] ; m [ 0 ] [ i ] = m [ rows - 1 ] [ i ] ; m [ rows - 1 ] [ i ] = t ; } } public static void Main ( string [ ] args ) { int [ ] [ ] m = new int [ ] [ ] { new int [ ] { 8 , 9 , 7 , 6 } , new int [ ] { 4 , 7 , 6 , 5 } , new int [ ] { 3 , 2 , 1 , 8 } , new int [ ] { 9 , 9 , 7 , 7 } } ; interchangeFirstLast ( m ) ; for ( int i = 0 ; i < m . Length ; i ++ ) { for ( int j = 0 ; j < m [ 0 ] . Length ; j ++ ) { Console . Write ( m [ i ] [ j ] + " ▁ " ) ; } Console . WriteLine ( ) ; } } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class Node { public int key ; public Node left , right ; public Node ( int key ) { this . key = key ; left = right = null ; } } class GFG { public Node root ; public virtual void createNode ( int [ ] parent , int i , Node [ ] created ) { if ( created [ i ] != null ) { return ; } created [ i ] = new Node ( i ) ; if ( parent [ i ] == - 1 ) { root = created [ i ] ; return ; } if ( created [ parent [ i ] ] == null ) { createNode ( parent , parent [ i ] , created ) ; } Node p = created [ parent [ i ] ] ; if ( p . left == null ) { p . left = created [ i ] ; } else { p . right = created [ i ] ; } } public virtual Node createTree ( int [ ] parent , int n ) { Node [ ] created = new Node [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { created [ i ] = null ; } for ( int i = 0 ; i < n ; i ++ ) { createNode ( parent , i , created ) ; } return root ; } public virtual void newLine ( ) { Console . WriteLine ( " " ) ; } public virtual void inorder ( Node node ) { if ( node != null ) { inorder ( node . left ) ; Console . Write ( node . key + " ▁ " ) ; inorder ( node . right ) ; } } public static void Main ( string [ ] args ) { GFG tree = new GFG ( ) ; int [ ] parent = new int [ ] { - 1 , 0 , 0 , 1 , 1 , 3 , 5 } ; int n = parent . Length ; Node node = tree . createTree ( parent , n ) ; Console . WriteLine ( " Inorder ▁ traversal ▁ of ▁ " + " constructed ▁ tree ▁ " ) ; tree . inorder ( node ) ; tree . newLine ( ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Node
C# program:
using System ; class GFG { static int sortRowWise ( int [ , ] m ) { for ( int i = 0 ; i < m . GetLength ( 0 ) ; i ++ ) { for ( int j = 0 ; j < m . GetLength ( 1 ) ; j ++ ) { for ( int k = 0 ; k < m . GetLength ( 1 ) - j - 1 ; k ++ ) { if ( m [ i , k ] > m [ i , k + 1 ] ) { int t = m [ i , k ] ; m [ i , k ] = m [ i , k + 1 ] ; m [ i , k + 1 ] = t ; } } } } for ( int i = 0 ; i < m . GetLength ( 0 ) ; i ++ ) { for ( int j = 0 ; j < m . GetLength ( 1 ) ; j ++ ) Console . Write ( m [ i , j ] + " ▁ " ) ; Console . WriteLine ( ) ; } return 0 ; } public static void Main ( String [ ] args ) { int [ , ] m = { { 9 , 8 , 7 , 1 } , { 7 , 3 , 0 , 2 } , { 9 , 5 , 3 , 2 } , { 6 , 3 , 1 , 2 } } ; sortRowWise ( m ) ; } }

Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static bool checkMarkov ( double [ , ] m ) { for ( int i = 0 ; i < m . GetLength ( 0 ) ; i ++ ) { double sum = 0 ; for ( int j = 0 ; j < m . GetLength ( 1 ) ; j ++ ) sum = sum + m [ i , j ] ; if ( sum != 1 ) return false ; } return true ; } static void Main ( ) { double [ , ] m = new double [ , ] { { 0 , 0 , 1 } , { 0.5 , 0 , 0.5 } , { 1 , 0 , 0 } } ; if ( checkMarkov ( m ) ) Console . WriteLine ( " ▁ yes ▁ " ) ; else Console . WriteLine ( " ▁ no ▁ " ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int N = 4 ; static bool isDiagonalMatrix ( int [ , ] mat ) { for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) if ( ( i != j ) && ( mat [ i , j ] != 0 ) ) return false ; return true ; } public static void Main ( ) { int [ , ] mat = { { 4 , 0 , 0 , 0 } , { 0 , 7 , 0 , 0 } , { 0 , 0 , 5 , 0 } , { 0 , 0 , 0 , 1 } } ; if ( isDiagonalMatrix ( mat ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int N = 4 ; static bool isScalarMatrix ( int [ , ] mat ) { for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) if ( ( i != j ) && ( mat [ i , j ] != 0 ) ) return false ; for ( int i = 0 ; i < N - 1 ; i ++ ) if ( mat [ i , i ] != mat [ i + 1 , i + 1 ] ) return false ; return true ; } public static void Main ( ) { int [ , ] mat = { { 2 , 0 , 0 , 0 } , { 0 , 2 , 0 , 0 } , { 0 , 0 , 2 , 0 } , { 0 , 0 , 0 , 2 } } ; if ( isScalarMatrix ( mat ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int data ) { this . data = data ; left = right = null ; } } public class Index { public int index ; } class GFG { public virtual Node buildUtil ( int [ ] @in , int [ ] post , int inStrt , int inEnd , Index pIndex ) { if ( inStrt > inEnd ) { return null ; } Node node = new Node ( post [ pIndex . index ] ) ; ( pIndex . index ) -- ; if ( inStrt == inEnd ) { return node ; } int iIndex = search ( @in , inStrt , inEnd , node . data ) ; node . right = buildUtil ( @in , post , iIndex + 1 , inEnd , pIndex ) ; node . left = buildUtil ( @in , post , inStrt , iIndex - 1 , pIndex ) ; return node ; } public virtual Node buildTree ( int [ ] @in , int [ ] post , int n ) { Index pIndex = new Index ( ) ; pIndex . index = n - 1 ; return buildUtil ( @in , post , 0 , n - 1 , pIndex ) ; } public virtual int search ( int [ ] arr , int strt , int end , int value ) { int i ; for ( i = strt ; i <= end ; i ++ ) { if ( arr [ i ] == value ) { break ; } } return i ; } public virtual void preOrder ( Node node ) { if ( node == null ) { return ; } Console . Write ( node . data + " ▁ " ) ; preOrder ( node . left ) ; preOrder ( node . right ) ; } public static void Main ( string [ ] args ) { GFG tree = new GFG ( ) ; int [ ] @in = new int [ ] { 4 , 8 , 2 , 5 , 1 , 6 , 3 , 7 } ; int [ ] post = new int [ ] { 8 , 4 , 5 , 2 , 6 , 7 , 3 , 1 } ; int n = @in . Length ; Node root = tree . buildTree ( @in , post , n ) ; Console . WriteLine ( " Preorder ▁ of ▁ the ▁ constructed ▁ tree ▁ : ▁ " ) ; tree . preOrder ( root ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Index, Node
C# program:
using System ; class GFG { static int subCount ( int [ ] arr , int n , int k ) { int [ ] mod = new int [ k ] ; int cumSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { cumSum += arr [ i ] ; mod [ ( ( cumSum % k ) + k ) % k ] ++ ; } int result = 0 ; for ( int i = 0 ; i < k ; i ++ ) if ( mod [ i ] > 1 ) result += ( mod [ i ] * ( mod [ i ] - 1 ) ) / 2 ; result += mod [ 0 ] ; return result ; } static int countSubmatrix ( int [ , ] mat , int n , int k ) { int tot_count = 0 ; int left , right , i ; int [ ] temp = new int [ n ] ; for ( left = 0 ; left < n ; left ++ ) { for ( right = left ; right < n ; right ++ ) { for ( i = 0 ; i < n ; ++ i ) temp [ i ] += mat [ i , right ] ; tot_count += subCount ( temp , n , k ) ; } } return tot_count - 3 ; } static void Main ( ) { int [ , ] mat = new int [ , ] { { 5 , - 1 , 6 } , { - 2 , 3 , 8 } , { 7 , 4 , - 9 } } ; int n = 3 , k = 4 ; Console . Write ( " Count = " countSubmatrix ( mat , n , k ) ) ; } }

Index/key variables: i, k, n
Accumulator variables: cumSum, i, left, result, right, tot_count
Iterator variables: i, left, right
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMinOpeartion ( int [ , ] matrix , int n ) { int [ ] sumRow = new int [ n ] ; int [ ] sumCol = new int [ n ] ; for ( int i = 0 ; i < n ; ++ i ) for ( int j = 0 ; j < n ; ++ j ) { sumRow [ i ] += matrix [ i , j ] ; sumCol [ j ] += matrix [ i , j ] ; } int maxSum = 0 ; for ( int i = 0 ; i < n ; ++ i ) { maxSum = Math . Max ( maxSum , sumRow [ i ] ) ; maxSum = Math . Max ( maxSum , sumCol [ i ] ) ; } int count = 0 ; for ( int i = 0 , j = 0 ; i < n && j < n ; ) { int diff = Math . Min ( maxSum - sumRow [ i ] , maxSum - sumCol [ j ] ) ; matrix [ i , j ] += diff ; sumRow [ i ] += diff ; sumCol [ j ] += diff ; count += diff ; if ( sumRow [ i ] == maxSum ) ++ i ; if ( sumCol [ j ] == maxSum ) ++ j ; } return count ; } static void printMatrix ( int [ , ] matrix , int n ) { for ( int i = 0 ; i < n ; ++ i ) { for ( int j = 0 ; j < n ; ++ j ) Console . Write ( matrix [ i , j ] + " ▁ " ) ; Console . WriteLine ( ) ; } } public static void Main ( ) { int [ , ] matrix = { { 1 , 2 } , { 3 , 4 } } ; Console . WriteLine ( findMinOpeartion ( matrix , 2 ) ) ; printMatrix ( matrix , 2 ) ; } }

Index/key variables: i, j, n
Accumulator variables: count
Iterator variables: i, j
Class/struct names: GFG