dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; public class GFG { public 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 void preOrder ( Node node ) { if ( node == null ) return ; Console . Write ( " { 0 } ▁ " , node . data ) ; preOrder ( node . left ) ; preOrder ( node . right ) ; } static int findIndex ( String str , int si , int ei ) { if ( si > ei ) return - 1 ; Stack < char > s = new Stack < char > ( ) ; for ( int i = si ; i <= ei ; i ++ ) { if ( str [ i ] == ' ( ' ) s . Push ( str [ i ] ) ; else if ( str [ i ] == ' ) ' ) { if ( s . Peek ( ) == ' ( ' ) { s . Pop ( ) ; if ( s . Count == 0 ) return i ; } } } return - 1 ; } static Node treeFromString ( String str , int si , int ei ) { if ( si > ei ) return null ; Node root = newNode ( str [ si ] - '0' ) ; int index = - 1 ; if ( si + 1 <= ei && str [ si + 1 ] == ' ( ' ) index = findIndex ( str , si + 1 , ei ) ; if ( index != - 1 ) { root . left = treeFromString ( str , si + 2 , index - 1 ) ; root . right = treeFromString ( str , index + 2 , ei - 1 ) ; } return root ; } public static void Main ( String [ ] args ) { String str = "4(2(3 ) ( 1 ) ) (6(5 ) ) " ; Node root = treeFromString ( str , 0 , str . Length - 1 ) ; preOrder ( root ) ; } }

Index/key variables: i, si
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { public class node { public int val ; public node left ; public node right ; public node ( ) { this . val = 0 ; this . left = null ; this . right = null ; } public node ( int x ) { this . val = x ; this . left = null ; this . right = null ; } public node ( int x , node left , node right ) { this . val = x ; this . left = left ; this . right = right ; } } ; static bool continuous ( node root ) { if ( root == null ) return false ; int flag = 1 ; Queue < node > Q = new Queue < node > ( ) ; Q . Enqueue ( root ) ; node temp ; while ( Q . Count != 0 ) { temp = Q . Peek ( ) ; Q . Dequeue ( ) ; if ( temp . left != null ) { if ( Math . Abs ( temp . left . val - temp . val ) == 1 ) Q . Enqueue ( temp . left ) ; else { flag = 0 ; break ; } } if ( temp . right != null ) { if ( Math . Abs ( temp . right . val - temp . val ) == 1 ) Q . Enqueue ( temp . right ) ; else { flag = 0 ; break ; } } } if ( flag != 0 ) return true ; else return false ; } public static void Main ( String [ ] args ) { node root = new node ( 3 ) ; root . left = new node ( 2 ) ; root . right = new node ( 4 ) ; root . left . left = new node ( 1 ) ; root . left . right = new node ( 3 ) ; root . right . right = new node ( 5 ) ; if ( continuous ( root ) ) Console . Write ( " True STRNEWLINE " ) ; else Console . Write ( " False STRNEWLINE " ) ; } }

Class/struct names: GFG, node
C# program:
using System ; class GFG { static int MAX = 100 ; static void printMatrixDiagonal ( int [ , ] mat , int n ) { int i = 0 , j = 0 ; bool isUp = true ; for ( int k = 0 ; k < n * n ; ) { if ( isUp ) { for ( ; i >= 0 && j < n ; j ++ , i -- ) { Console . Write ( mat [ i , j ] + " ▁ " ) ; k ++ ; } if ( i < 0 && j <= n - 1 ) i = 0 ; if ( j == n ) { i = i + 2 ; j -- ; } } else { for ( ; j >= 0 && i < n ; i ++ , j -- ) { Console . Write ( mat [ i , j ] + " ▁ " ) ; k ++ ; } if ( j < 0 && i <= n - 1 ) j = 0 ; if ( i == n ) { j = j + 2 ; i -- ; } } isUp = ! isUp ; } } public static void Main ( ) { int [ , ] mat = { { 1 , 2 , 3 } , { 4 , 5 , 6 } , { 7 , 8 , 9 } } ; int n = 3 ; printMatrixDiagonal ( mat , n ) ; } }

Accumulator variables: i, j, k
Iterator variables: k
Boolean variables: isUp
Class/struct names: GFG
C# program:
using System ; public class MatrixDiag { public static void Main ( String [ ] args ) { int [ , ] mat = { { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } , { 9 , 10 , 11 , 12 } , { 13 , 14 , 15 , 16 } } ; int n = 4 , mode = 0 , it = 0 , lower = 0 ; for ( int t = 0 ; t < ( 2 * n - 1 ) ; t ++ ) { int t1 = t ; if ( t1 >= n ) { mode ++ ; t1 = n - 1 ; it -- ; lower ++ ; } else { lower = 0 ; it ++ ; } for ( int i = t1 ; i >= lower ; i -- ) { if ( ( t1 + mode ) % 2 == 0 ) { Console . WriteLine ( mat [ i , t1 + lower - i ] ) ; } else { Console . WriteLine ( mat [ t1 + lower - i , i ] ) ; } } } } }

Accumulator variables: i, it, lower, mode, t
Iterator variables: i, t
Class/struct names: MatrixDiag
C# program:
using System ; class GFG { static int maxRowDiff ( int [ , ] mat , int m , int n ) { int [ ] rowSum = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { int sum = 0 ; for ( int j = 0 ; j < n ; j ++ ) sum += mat [ i , j ] ; rowSum [ i ] = sum ; } int max_diff = rowSum [ 1 ] - rowSum [ 0 ] ; int min_element = rowSum [ 0 ] ; for ( int i = 1 ; i < m ; i ++ ) { if ( rowSum [ i ] - min_element > max_diff ) max_diff = rowSum [ i ] - min_element ; if ( rowSum [ i ] < min_element ) min_element = rowSum [ i ] ; } return max_diff ; } public static void Main ( ) { int m = 5 , n = 4 ; int [ , ] mat = { { - 1 , 2 , 3 , 4 } , { 5 , 3 , - 2 , 1 } , { 6 , 7 , 2 , - 3 } , { 2 , 9 , 1 , 4 } , { 2 , 1 , - 2 , 0 } } ; Console . Write ( maxRowDiff ( mat , m , n ) ) ; } }

Index/key variables: i, m
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int R = 4 ; static int C = 4 ; static int getTotalCoverageOfMatrix ( int [ , ] mat ) { int res = 0 ; for ( int i = 0 ; i < R ; i ++ ) { bool isOne = false ; for ( int j = 0 ; j < C ; j ++ ) { if ( mat [ i , j ] == 1 ) isOne = true ; else if ( isOne ) res ++ ; } isOne = false ; for ( int j = C - 1 ; j >= 0 ; j -- ) { if ( mat [ i , j ] == 1 ) isOne = true ; else if ( isOne ) res ++ ; } } for ( int j = 0 ; j < C ; j ++ ) { bool isOne = false ; for ( int i = 0 ; i < R ; i ++ ) { if ( mat [ i , j ] == 1 ) isOne = true ; else if ( isOne ) res ++ ; } isOne = false ; for ( int i = R - 1 ; i >= 0 ; i -- ) { if ( mat [ i , j ] == 1 ) isOne = true ; else if ( isOne ) res ++ ; } } return res ; } static public void Main ( ) { int [ , ] mat = { { 0 , 0 , 0 , 0 } , { 1 , 0 , 0 , 1 } , { 0 , 1 , 1 , 0 } , { 0 , 1 , 0 , 0 } } ; Console . WriteLine ( getTotalCoverageOfMatrix ( mat ) ) ; } }

Accumulator variables: i, j, res
Iterator variables: i, j
Boolean variables: isOne
Class/struct names: GFG
C# program:
using System ; class GFG { static int sortedCount ( int [ , ] mat , int r , int c ) { int result = 0 ; for ( int i = 0 ; i < r ; i ++ ) { int j ; for ( j = 0 ; j < c - 1 ; j ++ ) if ( mat [ i , j + 1 ] <= mat [ i , j ] ) break ; if ( j == c - 1 ) result ++ ; } for ( int i = 0 ; i < r ; i ++ ) { int j ; for ( j = c - 1 ; j > 0 ; j -- ) if ( mat [ i , j - 1 ] <= mat [ i , j ] ) break ; if ( c > 1 && j == 0 ) result ++ ; } return result ; } public static void Main ( ) { int m = 4 , n = 5 ; int [ , ] mat = { { 1 , 2 , 3 , 4 , 5 } , { 4 , 3 , 1 , 2 , 6 } , { 8 , 7 , 6 , 5 , 4 } , { 5 , 7 , 8 , 9 , 10 } } ; Console . WriteLine ( sortedCount ( mat , m , n ) ) ; } }

Accumulator variables: i, j, result
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void preprocessMatrix ( int [ ] rows , int [ ] cols , int m , int n ) { for ( int i = 0 ; i < m ; i ++ ) { rows [ i ] = i ; } for ( int i = 0 ; i < n ; i ++ ) { cols [ i ] = i ; } } static void queryMatrix ( int [ ] rows , int [ ] cols , int m , int n , char ch , int x , int y ) { int tmp ; switch ( ch ) { case ' R ' : swap ( rows , x - 1 , y - 1 ) ; break ; case ' C ' : swap ( cols , x - 1 , y - 1 ) ; break ; case ' P ' : Console . Write ( " value ▁ at ▁ ( { 0 } , ▁ { 1 } ) ▁ = ▁ { 2 } STRNEWLINE " , x , y , rows [ x - 1 ] * n + cols [ y - 1 ] + 1 ) ; break ; } return ; } static int [ ] swap ( int [ ] arr , int i , int j ) { int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; return arr ; } public static void Main ( ) { int m = 1234 , n = 5678 ; int [ ] rows = new int [ m ] ; int [ ] cols = new int [ n ] ; preprocessMatrix ( rows , cols , m , n ) ; queryMatrix ( rows , cols , m , n , ' R ' , 1 , 2 ) ; queryMatrix ( rows , cols , m , n , ' P ' , 1 , 1 ) ; queryMatrix ( rows , cols , m , n , ' P ' , 2 , 1 ) ; queryMatrix ( rows , cols , m , n , ' C ' , 1 , 2 ) ; queryMatrix ( rows , cols , m , n , ' P ' , 1 , 1 ) ; queryMatrix ( rows , cols , m , n , ' P ' , 2 , 1 ) ; } }

Index/key variables: i, j, m, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxXOR ( int [ , ] mat , int N ) { int r_xor , c_xor ; int max_xor = 0 ; for ( int i = 0 ; i < N ; i ++ ) { r_xor = 0 ; c_xor = 0 ; for ( int j = 0 ; j < N ; j ++ ) { r_xor = r_xor ^ mat [ i , j ] ; c_xor = c_xor ^ mat [ j , i ] ; } if ( max_xor < Math . Max ( r_xor , c_xor ) ) max_xor = Math . Max ( r_xor , c_xor ) ; } return max_xor ; } public static void Main ( ) { int N = 3 ; int [ , ] mat = { { 1 , 5 , 4 } , { 3 , 7 , 2 } , { 5 , 9 , 10 } } ; Console . Write ( " maximum ▁ XOR ▁ value ▁ : ▁ " + maxXOR ( mat , N ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int maximumMirrorInMatrix ( String [ ] mat , int N ) { int [ ] horizontal = new int [ N ] ; int [ ] vertical = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { horizontal [ i ] = - 1 ; vertical [ i ] = - 1 ; } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = N - 1 ; j >= 0 ; j -- ) { if ( mat [ i ] [ j ] == ' B ' ) { continue ; } horizontal [ i ] = j ; break ; } } for ( int j = 0 ; j < N ; j ++ ) { for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( mat [ i ] [ j ] == ' B ' ) { continue ; } vertical [ j ] = i ; break ; } } int res = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( i > vertical [ j ] && j > horizontal [ i ] ) { res ++ ; } } } return res ; } public static void Main ( String [ ] args ) { int N = 5 ; String [ ] mat = { " BBOBB " , " BBBBO " , " BBBBB " , " BOOBO " , " BBBOB " } ; Console . WriteLine ( maximumMirrorInMatrix ( mat , N ) ) ; } }

Index/key variables: N, i, j
Accumulator variables: i, j, res
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void direction ( int R , int C ) { if ( R != C && R % 2 == 0 && C % 2 != 0 && R < C ) { Console . WriteLine ( " Left " ) ; return ; } if ( R != C && R % 2 != 0 && C % 2 == 0 && R > C ) { Console . WriteLine ( " Up " ) ; return ; } if ( R == C && R % 2 != 0 && C % 2 != 0 ) { Console . WriteLine ( " Right " ) ; return ; } if ( R == C && R % 2 == 0 && C % 2 == 0 ) { Console . WriteLine ( " Left " ) ; return ; } if ( R != C && R % 2 != 0 && C % 2 != 0 && R < C ) { Console . WriteLine ( " Right " ) ; return ; } if ( R != C && R % 2 != 0 && C % 2 != 0 && R > C ) { Console . WriteLine ( " Down " ) ; return ; } if ( R != C && R % 2 == 0 && C % 2 == 0 && R < C ) { Console . WriteLine ( " Left " ) ; return ; } if ( R != C && R % 2 == 0 && C % 2 == 0 && R > C ) { Console . WriteLine ( " Up " ) ; return ; } if ( R != C && R % 2 == 0 && C % 2 != 0 && R > C ) { Console . WriteLine ( " Down " ) ; return ; } if ( R != C && R % 2 != 0 && C % 2 == 0 && R < C ) { Console . WriteLine ( " Right " ) ; return ; } } static public void Main ( ) { int R = 3 , C = 1 ; direction ( R , C ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int R = 3 ; static int C = 6 ; static void spiralPrint ( int m , int n , int [ , ] a , int c ) { int i , k = 0 , l = 0 ; int count = 0 ; while ( k < m && l < n ) { for ( i = l ; i < n ; ++ i ) { count ++ ; if ( count == c ) Console . WriteLine ( a [ k , i ] + " ▁ " ) ; } k ++ ; for ( i = k ; i < m ; ++ i ) { count ++ ; if ( count == c ) Console . WriteLine ( a [ i , n - 1 ] + " ▁ " ) ; } n -- ; if ( k < m ) { for ( i = n - 1 ; i >= l ; -- i ) { count ++ ; if ( count == c ) Console . WriteLine ( a [ m - 1 , i ] + " ▁ " ) ; } m -- ; } if ( l < n ) { for ( i = m - 1 ; i >= k ; -- i ) { count ++ ; if ( count == c ) Console . WriteLine ( a [ i , l ] + " ▁ " ) ; } l ++ ; } } } static void Main ( ) { int [ , ] a = { { 1 , 2 , 3 , 4 , 5 , 6 } , { 7 , 8 , 9 , 10 , 11 , 12 } , { 13 , 14 , 15 , 16 , 17 , 18 } } ; int k = 17 ; spiralPrint ( R , C , a , k ) ; } }

Accumulator variables: count, k, l, m, n
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findK ( int [ , ] A , int i , int j , int n , int m , int k ) { if ( n < 1 m < 1 ) return - 1 ; if ( k <= m ) return A [ i + 0 , j + k - 1 ] ; if ( k <= ( m + n - 1 ) ) return A [ i + ( k - m ) , j + m - 1 ] ; if ( k <= ( m + n - 1 + m - 1 ) ) return A [ i + n - 1 , j + m - 1 - ( k - ( m + n - 1 ) ) ] ; if ( k <= ( m + n - 1 + m - 1 + n - 2 ) ) return A [ i + n - 1 - ( k - ( m + n - 1 + m - 1 ) ) , j + 0 ] ; return findK ( A , i + 1 , j + 1 , n - 2 , m - 2 , k - ( 2 * n + 2 * m - 4 ) ) ; } static void Main ( ) { int [ , ] a = { { 1 , 2 , 3 , 4 , 5 , 6 } , { 7 , 8 , 9 , 10 , 11 , 12 } , { 13 , 14 , 15 , 16 , 17 , 18 } } ; int k = 17 ; Console . WriteLine ( findK ( a , 0 , 0 , 3 , 6 , k ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public static int N = 5 ; static int countZeroes ( int [ , ] mat ) { int row = N - 1 , col = 0 ; int count = 0 ; while ( col < N ) { while ( mat [ row , col ] > 0 ) if ( -- row < 0 ) return count ; count += ( row + 1 ) ; col ++ ; } return count ; } public static void Main ( ) { int [ , ] mat = { { 0 , 0 , 0 , 0 , 1 } , { 0 , 0 , 0 , 1 , 1 } , { 0 , 1 , 1 , 1 , 1 } , { 1 , 1 , 1 , 1 , 1 } , { 1 , 1 , 1 , 1 , 1 } } ; Console . WriteLine ( countZeroes ( mat ) ) ; } }

Accumulator variables: col, count
Class/struct names: GFG
C# program:
using System ; class GFG { static int N = 10 ; static int findLargestPlus ( int [ , ] mat ) { int [ , ] left = new int [ N , N ] ; int [ , ] right = new int [ N , N ] ; int [ , ] top = new int [ N , N ] ; int [ , ] bottom = new int [ N , N ] ; for ( int i = 0 ; i < N ; i ++ ) { top [ 0 , i ] = mat [ 0 , i ] ; bottom [ N - 1 , i ] = mat [ N - 1 , i ] ; left [ i , 0 ] = mat [ i , 0 ] ; right [ i , N - 1 ] = mat [ i , N - 1 ] ; } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 1 ; j < N ; j ++ ) { if ( mat [ i , j ] == 1 ) left [ i , j ] = left [ i , j - 1 ] + 1 ; else left [ i , j ] = 0 ; if ( mat [ j , i ] == 1 ) top [ j , i ] = top [ j - 1 , i ] + 1 ; else top [ j , i ] = 0 ; j = N - 1 - j ; if ( mat [ j , i ] == 1 ) bottom [ j , i ] = bottom [ j + 1 , i ] + 1 ; else bottom [ j , i ] = 0 ; if ( mat [ i , j ] == 1 ) right [ i , j ] = right [ i , j + 1 ] + 1 ; else right [ i , j ] = 0 ; j = N - 1 - j ; } } int n = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { int len = Math . Min ( Math . Min ( top [ i , j ] , bottom [ i , j ] ) , Math . Min ( left [ i , j ] , right [ i , j ] ) ) ; if ( len > n ) n = len ; } } if ( n > 0 ) return 4 * ( n - 1 ) + 1 ; return 0 ; } public static void Main ( ) { int [ , ] mat = { { 1 , 0 , 1 , 1 , 1 , 1 , 0 , 1 , 1 , 1 } , { 1 , 0 , 1 , 0 , 1 , 1 , 1 , 0 , 1 , 1 } , { 1 , 1 , 1 , 0 , 1 , 1 , 0 , 1 , 0 , 1 } , { 0 , 0 , 0 , 0 , 1 , 0 , 0 , 1 , 0 , 0 } , { 1 , 1 , 1 , 0 , 1 , 1 , 1 , 1 , 1 , 1 } , { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 } , { 1 , 0 , 0 , 0 , 1 , 0 , 0 , 1 , 0 , 1 } , { 1 , 0 , 1 , 1 , 1 , 1 , 0 , 0 , 1 , 1 } , { 1 , 1 , 0 , 0 , 1 , 0 , 1 , 0 , 0 , 1 } , { 1 , 0 , 1 , 1 , 1 , 1 , 0 , 1 , 0 , 0 } } ; Console . Write ( findLargestPlus ( mat ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Text ; public class GFG { public static StringBuilder findLeft ( StringBuilder str ) { int n = str . Length ; while ( n > 0 ) { n -- ; if ( str [ n ] == ' d ' ) { str [ n ] = ' c ' ; break ; } if ( str [ n ] == ' b ' ) { str [ n ] = ' a ' ; break ; } if ( str [ n ] == ' a ' ) { str [ n ] = ' b ' ; } else if ( str [ n ] == ' c ' ) { str [ n ] = ' d ' ; } } return str ; } public static void Main ( string [ ] args ) { StringBuilder str = new StringBuilder ( " aacbddc " ) ; Console . Write ( " Left ▁ of ▁ " + str + " ▁ is ▁ " + findLeft ( str ) ) ; } }

Index/key variables: n
Accumulator variables: n
Class/struct names: GFG
C# program:
using System ; class GFG { static void printSpiral ( int n ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { int x ; x = Math . Min ( Math . Min ( i , j ) , Math . Min ( n - 1 - i , n - 1 - j ) ) ; if ( i <= j ) Console . Write ( ( n - 2 * x ) * ( n - 2 * x ) - ( i - x ) - ( j - x ) + " TABSYMBOL " ) ; else Console . Write ( ( n - 2 * x - 2 ) * ( n - 2 * x - 2 ) + ( i - x ) + ( j - x ) + " TABSYMBOL " ) ; } Console . WriteLine ( ) ; } } public static void Main ( ) { int n = 5 ; printSpiral ( n ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int ROW = 9 ; static int COL = 10 ; public class Point { public int x ; public int y ; public Point ( int x , int y ) { this . x = x ; this . y = y ; } } ; public class queueNode { public Point pt ; public int dist ; public queueNode ( Point pt , int dist ) { this . pt = pt ; this . dist = dist ; } } ; static bool isValid ( int row , int col ) { return ( row >= 0 ) && ( row < ROW ) && ( col >= 0 ) && ( col < COL ) ; } static int [ ] rowNum = { - 1 , 0 , 0 , 1 } ; static int [ ] colNum = { 0 , - 1 , 1 , 0 } ; static int BFS ( int [ , ] mat , Point src , Point dest ) { if ( mat [ src . x , src . y ] != 1 mat [ dest . x , dest . y ] != 1 ) return - 1 ; bool [ , ] visited = new bool [ ROW , COL ] ; visited [ src . x , src . y ] = true ; Queue < queueNode > q = new Queue < queueNode > ( ) ; queueNode s = new queueNode ( src , 0 ) ; q . Enqueue ( s ) ; while ( q . Count != 0 ) { queueNode curr = q . Peek ( ) ; Point pt = curr . pt ; if ( pt . x == dest . x && pt . y == dest . y ) return curr . dist ; q . Dequeue ( ) ; for ( int i = 0 ; i < 4 ; i ++ ) { int row = pt . x + rowNum [ i ] ; int col = pt . y + colNum [ i ] ; if ( isValid ( row , col ) && mat [ row , col ] == 1 && ! visited [ row , col ] ) { visited [ row , col ] = true ; queueNode Adjcell = new queueNode ( new Point ( row , col ) , curr . dist + 1 ) ; q . Enqueue ( Adjcell ) ; } } } return - 1 ; } public static void Main ( String [ ] args ) { int [ , ] mat = { { 1 , 0 , 1 , 1 , 1 , 1 , 0 , 1 , 1 , 1 } , { 1 , 0 , 1 , 0 , 1 , 1 , 1 , 0 , 1 , 1 } , { 1 , 1 , 1 , 0 , 1 , 1 , 0 , 1 , 0 , 1 } , { 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 } , { 1 , 1 , 1 , 0 , 1 , 1 , 1 , 0 , 1 , 0 } , { 1 , 0 , 1 , 1 , 1 , 1 , 0 , 1 , 0 , 0 } , { 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 } , { 1 , 0 , 1 , 1 , 1 , 1 , 0 , 1 , 1 , 1 } , { 1 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 1 } } ; Point source = new Point ( 0 , 0 ) ; Point dest = new Point ( 3 , 4 ) ; int dist = BFS ( mat , source , dest ) ; if ( dist != - 1 ) Console . WriteLine ( " Shortest ▁ Path ▁ is ▁ " + dist ) ; else Console . WriteLine ( " Shortest ▁ Path ▁ doesn ' t ▁ exist " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Point, queueNode
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 { public Node root ; public virtual Node bintree2listUtil ( Node node ) { if ( node == null ) { return node ; } if ( node . left != null ) { Node left = bintree2listUtil ( node . left ) ; for ( ; left . right != null ; left = left . right ) { ; } left . right = node ; node . left = left ; } if ( node . right != null ) { Node right = bintree2listUtil ( node . right ) ; for ( ; right . left != null ; right = right . left ) { ; } right . left = node ; node . right = right ; } return node ; } public virtual Node bintree2list ( Node node ) { if ( node == null ) { return node ; } node = bintree2listUtil ( node ) ; while ( node . left != null ) { node = node . left ; } return node ; } public virtual void printList ( Node node ) { while ( node != null ) { Console . Write ( node . data + " ▁ " ) ; node = node . right ; } } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 10 ) ; tree . root . left = new Node ( 12 ) ; tree . root . right = new Node ( 15 ) ; tree . root . left . left = new Node ( 25 ) ; tree . root . left . right = new Node ( 30 ) ; tree . root . right . left = new Node ( 36 ) ; Node head = tree . bintree2list ( tree . root ) ; tree . printList ( head ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; class GFG { public static void modifyMatrix ( int [ , ] mat , int R , int C ) { int [ ] row = new int [ R ] ; int [ ] col = new int [ C ] ; int i , j ; for ( i = 0 ; i < R ; i ++ ) { row [ i ] = 0 ; } for ( i = 0 ; i < C ; i ++ ) { col [ i ] = 0 ; } for ( i = 0 ; i < R ; i ++ ) { for ( j = 0 ; j < C ; j ++ ) { if ( mat [ i , j ] == 1 ) { row [ i ] = 1 ; col [ j ] = 1 ; } } } for ( i = 0 ; i < R ; i ++ ) { for ( j = 0 ; j < C ; j ++ ) { if ( row [ i ] == 1 col [ j ] == 1 ) { mat [ i , j ] = 1 ; } } } } public static void printMatrix ( int [ , ] mat , int R , int C ) { int i , j ; for ( i = 0 ; i < R ; i ++ ) { for ( j = 0 ; j < C ; j ++ ) { Console . Write ( mat [ i , j ] + " ▁ " ) ; } Console . WriteLine ( ) ; } } static public void Main ( ) { int [ , ] mat = { { 1 , 0 , 0 , 1 } , { 0 , 0 , 1 , 0 } , { 0 , 0 , 0 , 0 } } ; Console . WriteLine ( " Matrix ▁ Intially " ) ; printMatrix ( mat , 3 , 4 ) ; modifyMatrix ( mat , 3 , 4 ) ; Console . WriteLine ( " Matrix ▁ after ▁ " + " modification ▁ n " ) ; printMatrix ( mat , 3 , 4 ) ; } }

Index/key variables: C, R, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static void modifyMatrix ( int [ , ] mat ) { bool row_flag = false ; bool col_flag = false ; for ( int i = 0 ; i < mat . GetLength ( 0 ) ; i ++ ) { for ( int j = 0 ; j < mat . GetLength ( 1 ) ; j ++ ) { if ( i == 0 && mat [ i , j ] == 1 ) row_flag = true ; if ( j == 0 && mat [ i , j ] == 1 ) col_flag = true ; if ( mat [ i , j ] == 1 ) { mat [ 0 , j ] = 1 ; mat [ i , 0 ] = 1 ; } } } for ( int i = 1 ; i < mat . GetLength ( 0 ) ; i ++ ) { for ( int j = 1 ; j < mat . GetLength ( 1 ) ; j ++ ) { if ( mat [ 0 , j ] == 1 mat [ i , 0 ] == 1 ) { mat [ i , j ] = 1 ; } } } if ( row_flag == true ) { for ( int i = 0 ; i < mat . GetLength ( 1 ) ; i ++ ) { mat [ 0 , i ] = 1 ; } } if ( col_flag == true ) { for ( int i = 0 ; i < mat . GetLength ( 0 ) ; i ++ ) { mat [ i , 0 ] = 1 ; } } } public static void printMatrix ( int [ , ] mat ) { for ( int i = 0 ; i < mat . GetLength ( 0 ) ; i ++ ) { for ( int j = 0 ; j < mat . GetLength ( 1 ) ; j ++ ) { Console . Write ( mat [ i , j ] + " ▁ " ) ; } Console . Write ( " STRNEWLINE " ) ; } } public static void Main ( ) { int [ , ] mat = { { 1 , 0 , 0 , 1 } , { 0 , 0 , 1 , 0 } , { 0 , 0 , 0 , 0 } } ; Console . Write ( " Input ▁ Matrix ▁ : STRNEWLINE " ) ; printMatrix ( mat ) ; modifyMatrix ( mat ) ; Console . Write ( " Matrix ▁ After ▁ " + " Modification ▁ : STRNEWLINE " ) ; printMatrix ( mat ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: col_flag, row_flag
Class/struct names: GFG
C# program:
using System ; public class GFG { static int n = 5 ; static int find ( bool [ , ] arr ) { int i = 0 , j = n - 1 ; int res = - 1 ; while ( i < n && j >= 0 ) { if ( arr [ i , j ] == false ) { while ( j >= 0 && ( arr [ i , j ] == false i == j ) ) { j -- ; } if ( j == - 1 ) { res = i ; break ; } else { i ++ ; } } else { while ( i < n && ( arr [ i , j ] == true i == j ) ) { i ++ ; } if ( i == n ) { res = j ; break ; } else { j -- ; } } } if ( res == - 1 ) { return res ; } for ( int k = 0 ; k < n ; k ++ ) { if ( res != k && arr [ k , res ] != true ) { return - 1 ; } } for ( int l = 0 ; l < n ; l ++ ) { if ( res != l && arr [ res , l ] != false ) { return - 1 ; } } return res ; } public static void Main ( ) { bool [ , ] mat = { { false , false , true , true , false } , { false , false , false , true , false } , { true , true , true , true , false } , { false , false , false , false , false } , { true , true , true , true , true } } ; Console . WriteLine ( find ( mat ) ) ; } }

Accumulator variables: i, j, k, l
Iterator variables: k, l
Class/struct names: GFG