dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int count ( int x , int [ ] Y , int n , int [ ] NoOfY ) { if ( x == 0 ) return 0 ; if ( x == 1 ) return NoOfY [ 0 ] ; int idx = Array . BinarySearch ( Y , x ) ; int ans ; if ( idx < 0 ) { idx = Math . Abs ( idx + 1 ) ; ans = Y . Length - idx ; } else { while ( idx < n && Y [ idx ] == x ) { idx ++ ; } ans = Y . Length - idx ; } ans += ( NoOfY [ 0 ] + NoOfY [ 1 ] ) ; if ( x == 2 ) ans -= ( NoOfY [ 3 ] + NoOfY [ 4 ] ) ; if ( x == 3 ) ans += NoOfY [ 2 ] ; return ans ; } static int countPairs ( int [ ] X , int [ ] Y , int m , int n ) { int [ ] NoOfY = new int [ 5 ] ; for ( int i = 0 ; i < n ; i ++ ) if ( Y [ i ] < 5 ) NoOfY [ Y [ i ] ] ++ ; Array . Sort ( Y ) ; int total_pairs = 0 ; for ( int i = 0 ; i < m ; i ++ ) total_pairs += count ( X [ i ] , Y , n , NoOfY ) ; return total_pairs ; } public static void Main ( ) { int [ ] X = { 2 , 1 , 6 } ; int [ ] Y = { 1 , 5 } ; Console . Write ( " Total ▁ pairs ▁ = ▁ " + countPairs ( X , Y , X . Length , Y . Length ) ) ; } }

Index/key variables: i, idx
Accumulator variables: ans, i, idx, total_pairs
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countPairsWithDiffK ( int [ ] arr , int n , int k ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) if ( arr [ i ] - arr [ j ] == k arr [ j ] - arr [ i ] == k ) count ++ ; } return count ; } public static void Main ( ) { int [ ] arr = { 1 , 5 , 3 , 4 , 2 } ; int n = arr . Length ; int k = 3 ; Console . WriteLine ( " Count ▁ of ▁ pairs ▁ with ▁ " + " ▁ given ▁ diff ▁ is ▁ " + countPairsWithDiffK ( 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 { static int binarySearch ( int [ ] arr , int low , int high , int x ) { if ( high >= low ) { int mid = low + ( high - low ) / 2 ; if ( x == arr [ mid ] ) return mid ; if ( x > arr [ mid ] ) return binarySearch ( arr , ( mid + 1 ) , high , x ) ; else return binarySearch ( arr , low , ( mid - 1 ) , x ) ; } return - 1 ; } static int countPairsWithDiffK ( int [ ] arr , int n , int k ) { int count = 0 , i ; Array . Sort ( arr ) ; / * remove duplicates from arr [ ] for ( i = 0 ; i < n - 1 ; i ++ ) if ( binarySearch ( arr , i + 1 , n - 1 , arr [ i ] + k ) != - 1 ) count ++ ; return count ; } public static void Main ( ) { int [ ] arr = { 1 , 5 , 3 , 4 , 2 } ; int n = arr . Length ; int k = 3 ; Console . WriteLine ( " Count ▁ of ▁ pairs ▁ with " + " ▁ given ▁ diff ▁ is ▁ " + countPairsWithDiffK ( arr , n , k ) ) ; } }

Index/key variables: i, mid
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countPairsWithDiffK ( int [ ] arr , int n , int k ) { int count = 0 ; Array . Sort ( arr ) ; int l = 0 ; int r = 0 ; while ( r < n ) { if ( arr [ r ] - arr [ l ] == k ) { count ++ ; l ++ ; r ++ ; } else if ( arr [ r ] - arr [ l ] > k ) l ++ ; else r ++ ; } return count ; } public static void Main ( ) { int [ ] arr = { 1 , 5 , 3 , 4 , 2 } ; int n = arr . Length ; int k = 3 ; Console . Write ( " Count ▁ of ▁ pairs ▁ with ▁ " + " given ▁ diff ▁ is ▁ " + countPairsWithDiffK ( arr , n , k ) ) ; } }

Index/key variables: l, r
Accumulator variables: count, l, r
Class/struct names: GFG
C# program:
using System ; class GFG { static int BS ( int [ ] arr , int X , int low ) { int high = arr . Length - 1 ; int ans = arr . Length ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( arr [ mid ] >= X ) { ans = mid ; high = mid - 1 ; } else low = mid + 1 ; } return ans ; } static int countPairsWithDiffK ( int [ ] arr , int N , int k ) { int count = 0 ; Array . Sort ( arr ) ; for ( int i = 0 ; i < N ; ++ i ) { int X = BS ( arr , arr [ i ] + k , i + 1 ) ; if ( X != N ) { int Y = BS ( arr , arr [ i ] + k + 1 , i + 1 ) ; count += Y - X ; } } return count ; } public static void Main ( string [ ] args ) { int [ ] arr = { 1 , 3 , 5 , 8 , 6 , 4 , 6 } ; int n = arr . Length ; int k = 2 ; Console . WriteLine ( " Count ▁ of ▁ pairs ▁ with ▁ given ▁ diff ▁ is ▁ " + countPairsWithDiffK ( arr , n , k ) ) ; } }

Index/key variables: i, mid
Accumulator variables: count
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int n = 3 ; static void findPrefixCount ( int [ , ] p_arr , Boolean [ , ] set_bit ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = n - 1 ; j >= 0 ; j -- ) { if ( set_bit [ i , j ] ) continue ; if ( j != n - 1 ) p_arr [ i , j ] += p_arr [ i , j + 1 ] ; p_arr [ i , j ] += ( ! set_bit [ i , j ] ) ? 1 : 0 ; } } } public class pair { public int first , second ; public pair ( ) { } public pair ( int a , int b ) { first = a ; second = b ; } } static int matrixOrValueOne ( Boolean [ , ] set_bit ) { int [ , ] p_arr = new int [ n , n ] ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) p_arr [ i , j ] = 0 ; findPrefixCount ( p_arr , set_bit ) ; int count_zero_submatrices = 0 ; for ( int j = 0 ; j < n ; j ++ ) { int i = n - 1 ; Stack < pair > q = new Stack < pair > ( ) ; int to_sum = 0 ; while ( i >= 0 ) { int c = 0 ; while ( q . Count != 0 && q . Peek ( ) . first > p_arr [ i , j ] ) { to_sum -= ( q . Peek ( ) . second + 1 ) * ( q . Peek ( ) . first - p_arr [ i , j ] ) ; c += q . Peek ( ) . second + 1 ; q . Pop ( ) ; } to_sum += p_arr [ i , j ] ; count_zero_submatrices += to_sum ; q . Push ( new pair ( p_arr [ i , j ] , c ) ) ; i -- ; } } return ( n * ( n + 1 ) * n * ( n + 1 ) ) / 4 - count_zero_submatrices ; } static int sumOrMatrix ( int [ , ] arr ) { int sum = 0 ; int mul = 1 ; for ( int i = 0 ; i < 30 ; i ++ ) { Boolean [ , ] set_bit = new Boolean [ n , n ] ; for ( int R = 0 ; R < n ; R ++ ) for ( int C = 0 ; C < n ; C ++ ) set_bit [ R , C ] = ( ( arr [ R , C ] & ( 1 << i ) ) != 0 ) ; sum += ( mul * matrixOrValueOne ( set_bit ) ) ; mul *= 2 ; } return sum ; } public static void Main ( String [ ] args ) { int [ , ] arr = { { 9 , 7 , 4 } , { 8 , 9 , 2 } , { 11 , 11 , 5 } } ; Console . WriteLine ( sumOrMatrix ( arr ) ) ; } }

Accumulator variables: C, R, c, count_zero_submatrices, i, j, mul, sum, to_sum
Iterator variables: C, R, i, j
Class/struct names: GFG, pair
C# program:
using System ; class GFG { static int MOD = 1000000007 ; static int totalSubSets ( int n , int l , int r ) { int zero = ( int ) Math . Floor ( ( double ) r / 3 ) - ( int ) Math . Ceiling ( ( double ) l / 3 ) + 1 ; int one = ( int ) Math . Floor ( ( double ) ( r - 1 ) / 3 ) - ( int ) Math . Ceiling ( ( double ) ( l - 1 ) / 3 ) + 1 ; int two = ( int ) Math . Floor ( ( double ) ( r - 2 ) / 3 ) - ( int ) Math . Ceiling ( ( double ) ( l - 2 ) / 3 ) + 1 ; int [ , ] dp = new int [ n , 3 ] ; dp [ 0 , 0 ] = zero ; dp [ 0 , 1 ] = one ; dp [ 0 , 2 ] = two ; for ( int i = 1 ; i < n ; ++ i ) { dp [ i , 0 ] = ( ( dp [ i - 1 , 0 ] * zero ) + ( dp [ i - 1 , 1 ] * two ) + ( dp [ i - 1 , 2 ] * one ) ) % MOD ; dp [ i , 1 ] = ( ( dp [ i - 1 , 0 ] * one ) + ( dp [ i - 1 , 1 ] * zero ) + ( dp [ i - 1 , 2 ] * two ) ) % MOD ; dp [ i , 2 ] = ( ( dp [ i - 1 , 0 ] * two ) + ( dp [ i - 1 , 1 ] * one ) + ( dp [ i - 1 , 2 ] * zero ) ) % MOD ; } return dp [ n - 1 , 0 ] ; } public static void Main ( ) { int n = 5 ; int l = 10 ; int r = 100 ; Console . WriteLine ( totalSubSets ( n , l , r ) ) ; } }

Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class FindSumOfNotAdjacentNodes { public class Node { public int data ; public Node left , right ; public Node ( int data ) { this . data = data ; left = right = null ; } } ; public static Pair maxSumHelper ( Node root ) { Pair sum ; if ( root == null ) { sum = new Pair ( 0 , 0 ) ; return sum ; } Pair sum1 = maxSumHelper ( root . left ) ; Pair sum2 = maxSumHelper ( root . right ) ; Pair sum3 = new Pair ( 0 , 0 ) ; sum3 . first = sum1 . second + sum2 . second + root . data ; sum3 . second = Math . Max ( sum1 . first , sum1 . second ) + Math . Max ( sum2 . first , sum2 . second ) ; return sum3 ; } public static int maxSum ( Node root ) { Pair res = maxSumHelper ( root ) ; return Math . Max ( res . first , res . second ) ; } public static void Main ( ) { Node root = new Node ( 10 ) ; root . left = new Node ( 1 ) ; root . left . left = new Node ( 2 ) ; root . left . left . left = new Node ( 1 ) ; root . left . right = new Node ( 3 ) ; root . left . right . left = new Node ( 4 ) ; root . left . right . right = new Node ( 5 ) ; Console . Write ( maxSum ( root ) ) ; } } public class Pair { public int first , second ; public Pair ( int first , int second ) { this . first = first ; this . second = second ; } }

Class/struct names: FindSumOfNotAdjacentNodes, Node, Pair
C# program:
using System ; class GFG { static readonly int r = 4 ; static readonly int c = 4 ; static bool findmatch ( char [ , ] mat , String pat , int x , int y , int nrow , int ncol , int level ) { int l = pat . Length ; if ( level == l ) return true ; if ( x < 0 y < 0 x >= nrow y >= ncol ) return false ; if ( mat [ x , y ] == pat [ level ] ) { char temp = mat [ x , y ] ; mat [ x , y ] = ' # ' ; bool res = findmatch ( mat , pat , x - 1 , y , nrow , ncol , level + 1 ) | findmatch ( mat , pat , x + 1 , y , nrow , ncol , level + 1 ) | findmatch ( mat , pat , x , y - 1 , nrow , ncol , level + 1 ) | findmatch ( mat , pat , x , y + 1 , nrow , ncol , level + 1 ) ; mat [ x , y ] = temp ; return res ; } return false ; } static bool checkMatch ( char [ , ] mat , String pat , int nrow , int ncol ) { int l = pat . Length ; if ( l > nrow * ncol ) return false ; for ( int i = 0 ; i < nrow ; i ++ ) { for ( int j = 0 ; j < ncol ; j ++ ) { if ( mat [ i , j ] == pat [ 0 ] ) if ( findmatch ( mat , pat , i , j , nrow , ncol , 0 ) ) return true ; } } return false ; } public static void Main ( String [ ] args ) { char [ , ] grid = { { ' a ' , ' x ' , ' m ' , ' y ' } , { ' b ' , ' g ' , ' d ' , ' f ' } , { ' x ' , ' e ' , ' e ' , ' t ' } , { ' r ' , ' a ' , ' k ' , ' s ' } } ; if ( checkMatch ( grid , " geeks " , r , c ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Index/key variables: level
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class PairSum { static void constructArr ( int [ ] arr , int [ ] pair , int n ) { arr [ 0 ] = ( pair [ 0 ] + pair [ 1 ] - pair [ n - 1 ] ) / 2 ; for ( int i = 1 ; i < n ; i ++ ) arr [ i ] = pair [ i - 1 ] - arr [ 0 ] ; } public static void Main ( ) { int [ ] pair = { 15 , 13 , 11 , 10 , 12 , 10 , 9 , 8 , 7 , 5 } ; int n = 5 ; int [ ] arr = new int [ n ] ; constructArr ( arr , pair , n ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: PairSum
C# program:
using System ; class Solution { private static int OR ( int [ ] arr ) { int mOR = 0 ; for ( int i = 0 ; i < arr . Length ; ++ i ) { mOR |= arr [ i ] ; } return mOR ; } private static int maxSubset ( int [ ] arr , int i , int curOr , int curSize , int maxOr ) { if ( i == arr . Length ) { if ( curOr == maxOr ) { return curSize ; } else { return arr . Length ; } } int take = maxSubset ( arr , i + 1 , curOr arr [ i ] , curSize + 1 , ) ; int notTake = maxSubset ( arr , i + 1 , curOr , curSize , maxOr ) ; return Math . Min ( take , notTake ) ; } static void Main ( ) { int [ ] data = { 5 , 1 , 3 , 4 , 2 } ; int maxOr = OR ( data ) ; int maxSubsetSize = maxSubset ( data , 0 , 0 , 0 , maxOr ) ; Console . WriteLine ( maxSubsetSize ) ; } }

Index/key variables: i
Accumulator variables: mOR
Iterator variables: i
Class/struct names: Solution
C# program:
using System ; public class Test { static int [ ] arr1 = new int [ ] { 1 , 5 , 9 , 10 , 15 , 20 } ; static int [ ] arr2 = new int [ ] { 2 , 3 , 8 , 13 } ; static void merge ( int m , int n ) { for ( int i = n - 1 ; i >= 0 ; i -- ) { int j , last = arr1 [ m - 1 ] ; for ( j = m - 2 ; j >= 0 && arr1 [ j ] > arr2 [ i ] ; j -- ) arr1 [ j + 1 ] = arr1 [ j ] ; if ( j != m - 2 last > arr2 [ i ] ) { arr1 [ j + 1 ] = arr2 [ i ] ; arr2 [ i ] = last ; } } } public static void Main ( ) { merge ( arr1 . Length , arr2 . Length ) ; Console . Write ( " After ▁ Merging ▁ STRNEWLINE First ▁ Array : ▁ " ) ; for ( int i = 0 ; i < arr1 . Length ; i ++ ) { Console . Write ( arr1 [ i ] + " ▁ " ) ; } Console . Write ( " STRNEWLINE Second ▁ Array : ▁ " ) ; for ( int i = 0 ; i < arr2 . Length ; i ++ ) { Console . Write ( arr2 [ i ] + " ▁ " ) ; } } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: Test
C# program:
using System ; class GFG { static void gouldSequence ( int n ) { for ( int row_num = 1 ; row_num <= n ; row_num ++ ) { int count = 1 ; int c = 1 ; for ( int i = 1 ; i <= row_num ; i ++ ) { c = c * ( row_num - i ) / i ; if ( c % 2 == 1 ) count ++ ; } Console . Write ( count + " ▁ " ) ; } } public static void Main ( ) { int n = 16 ; gouldSequence ( n ) ; } }

Accumulator variables: count, i, row_num
Iterator variables: i, row_num
Class/struct names: GFG
C# program:
using System ; class GfG { public static int minMaxProduct ( int [ ] arr1 , int [ ] arr2 , int n1 , int n2 ) { Array . Sort ( arr1 ) ; Array . Sort ( arr2 ) ; return arr1 [ n1 - 1 ] * arr2 [ 0 ] ; } public static void Main ( ) { int [ ] arr1 = new int [ ] { 10 , 2 , 3 , 6 , 4 , 1 } ; int [ ] arr2 = new int [ ] { 5 , 1 , 4 , 2 , 6 , 9 } ; int n1 = 6 ; int n2 = 6 ; Console . WriteLine ( minMaxProduct ( arr1 , arr2 , n1 , n2 ) ) ; } }

Class/struct names: GfG
C# program:
using System ; public class GFG { public static int M = 100 ; public static int N = 100 ; static int find_min_odd_cost ( int [ , ] given , int m , int n ) { int [ , ] floor = new int [ M , N ] ; int min_odd_cost = 0 ; int i , j , temp ; for ( j = 0 ; j < n ; j ++ ) floor [ 0 , j ] = given [ 0 , j ] ; for ( i = 1 ; i < m ; i ++ ) for ( j = 0 ; j < n ; j ++ ) { if ( j == 0 ) { floor [ i , j ] = given [ i , j ] ; floor [ i , j ] += Math . Min ( floor [ i - 1 , j ] , floor [ i - 1 , j + 1 ] ) ; } else if ( j == n - 1 ) { floor [ i , j ] = given [ i , j ] ; floor [ i , j ] += Math . Min ( floor [ i - 1 , j ] , floor [ i - 1 , j - 1 ] ) ; } else { temp = Math . Min ( floor [ i - 1 , j ] , floor [ i - 1 , j - 1 ] ) ; temp = Math . Min ( temp , floor [ i - 1 , j + 1 ] ) ; floor [ i , j ] = given [ i , j ] + temp ; } } min_odd_cost = int . MaxValue ; for ( j = 0 ; j < n ; j ++ ) { if ( floor [ n - 1 , j ] % 2 == 1 ) { if ( min_odd_cost > floor [ n - 1 , j ] ) min_odd_cost = floor [ n - 1 , j ] ; } } if ( min_odd_cost == int . MinValue ) return - 1 ; return min_odd_cost ; } public static void Main ( ) { int m = 5 , n = 5 ; int [ , ] given = { { 1 , 2 , 3 , 4 , 6 } , { 1 , 2 , 3 , 4 , 5 } , { 1 , 2 , 3 , 4 , 5 } , { 1 , 2 , 3 , 4 , 5 } , { 100 , 2 , 3 , 4 , 5 } } ; Console . Write ( " Minimum ▁ odd ▁ cost ▁ is ▁ " + find_min_odd_cost ( given , m , n ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GfG { public static int minMaxProduct ( int [ ] arr1 , int [ ] arr2 , int n1 , int n2 ) { int max = arr1 [ 0 ] ; int min = arr2 [ 0 ] ; int i ; for ( i = 1 ; i < n1 && i < n2 ; ++ i ) { if ( arr1 [ i ] > max ) max = arr1 [ i ] ; if ( arr2 [ i ] < min ) min = arr2 [ i ] ; } while ( i < n1 ) { if ( arr1 [ i ] > max ) max = arr1 [ i ] ; i ++ ; } while ( i < n2 ) { if ( arr2 [ i ] < min ) min = arr2 [ i ] ; i ++ ; } return max * min ; } public static void Main ( ) { int [ ] arr1 = new int [ ] { 10 , 2 , 3 , 6 , 4 , 1 } ; int [ ] arr2 = new int [ ] { 5 , 1 , 4 , 2 , 6 , 9 } ; int n1 = 6 ; int n2 = 6 ; Console . WriteLine ( minMaxProduct ( arr1 , arr2 , n1 , n2 ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GfG
C# program:
using System ; class GFG { public static int getMax ( int [ ] A , int N ) { int [ ] B = new int [ N + 2 ] ; B [ 0 ] = B [ N + 1 ] = 1 ; for ( int i = 1 ; i <= N ; i ++ ) B [ i ] = A [ i - 1 ] ; int [ , ] dp = new int [ ( N + 2 ) , ( N + 2 ) ] ; for ( int length = 1 ; length < N + 1 ; length ++ ) { for ( int left = 1 ; left < N - length + 2 ; left ++ ) { int right = left + length - 1 ; for ( int last = left ; last < right + 1 ; last ++ ) { dp [ left , right ] = Math . Max ( dp [ left , right ] , dp [ left , last - 1 ] + B [ left - 1 ] * B [ last ] * B [ right + 1 ] + dp [ last + 1 , right ] ) ; } } } return dp [ 1 , N ] ; } public static void Main ( ) { int [ ] A = new int [ ] { 1 , 2 , 3 , 4 , 5 } ; int N = A . Length ; Console . WriteLine ( getMax ( A , N ) ) ; } }

Index/key variables: i, last
Accumulator variables: i, last, left, length
Iterator variables: i, last, left, length
Class/struct names: GFG
C# program:
using System ; class main { static int findElement ( int [ ] arr , int n , int key ) { for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] == key ) return i ; return - 1 ; } public static void Main ( ) { int [ ] arr = { 12 , 34 , 10 , 6 , 40 } ; int n = arr . Length ; int key = 40 ; int position = findElement ( arr , n , key ) ; if ( position == - 1 ) Console . WriteLine ( " Element ▁ not ▁ found " ) ; else Console . WriteLine ( " Element ▁ Found ▁ at ▁ Position : ▁ " + ( position + 1 ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: main
C# program:
using System ; class main { static int insertSorted ( int [ ] arr , int n , int key , int capacity ) { if ( n >= capacity ) return n ; arr [ n ] = key ; return ( n + 1 ) ; } public static void Main ( ) { int [ ] arr = new int [ 20 ] ; arr [ 0 ] = 12 ; arr [ 1 ] = 16 ; arr [ 2 ] = 20 ; arr [ 3 ] = 40 ; arr [ 4 ] = 50 ; arr [ 5 ] = 70 ; int capacity = 20 ; int n = 6 ; int i , key = 26 ; Console . Write ( " Before ▁ Insertion : ▁ " ) ; for ( i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; n = insertSorted ( arr , n , key , capacity ) ; Console . Write ( " After ▁ Insertion : ▁ " ) ; for ( i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: main
C# program:
using System ; class main { static int findElement ( int [ ] arr , int n , int key ) { int i ; for ( i = 0 ; i < n ; i ++ ) if ( arr [ i ] == key ) return i ; return - 1 ; } static int deleteElement ( int [ ] arr , int n , int key ) { int pos = findElement ( arr , n , key ) ; if ( pos == - 1 ) { Console . WriteLine ( " Element ▁ not ▁ found " ) ; return n ; } int i ; for ( i = pos ; i < n - 1 ; i ++ ) arr [ i ] = arr [ i + 1 ] ; return n - 1 ; } public static void Main ( ) { int i ; int [ ] arr = { 10 , 50 , 30 , 40 , 20 } ; int n = arr . Length ; int key = 30 ; Console . Write ( " Array ▁ before ▁ deletion ▁ " ) ; for ( i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; n = deleteElement ( arr , n , key ) ; Console . Write ( " Array ▁ after ▁ deletion ▁ " ) ; for ( i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: main
C# program:
using System ; public class GFG { public static int binarySearch ( int [ ] arr , int low , int high , int key ) { if ( high < low ) { return - 1 ; } int mid = ( low + high ) / 2 ; if ( key == arr [ mid ] ) { return mid ; } if ( key > arr [ mid ] ) { return binarySearch ( arr , ( mid + 1 ) , high , key ) ; } return binarySearch ( arr , low , ( mid - 1 ) , key ) ; } public static void Main ( string [ ] args ) { int [ ] arr = new int [ ] { 5 , 6 , 7 , 8 , 9 , 10 } ; int n , key ; n = arr . Length ; key = 10 ; Console . WriteLine ( " Index : ▁ " + binarySearch ( arr , 0 , n - 1 , key ) ) ; } }

Index/key variables: mid
Class/struct names: GFG
C# program:
using System ; public class GFG { public static int insertSorted ( int [ ] arr , int n , int key , int capacity ) { if ( n >= capacity ) { return n ; } int i ; for ( i = n - 1 ; ( i >= 0 && arr [ i ] > key ) ; i -- ) { arr [ i + 1 ] = arr [ i ] ; } arr [ i + 1 ] = key ; return ( n + 1 ) ; } public static void Main ( string [ ] args ) { int [ ] arr = new int [ 20 ] ; arr [ 0 ] = 12 ; arr [ 1 ] = 16 ; arr [ 2 ] = 20 ; arr [ 3 ] = 40 ; arr [ 4 ] = 50 ; arr [ 5 ] = 70 ; int capacity = arr . Length ; int n = 6 ; int key = 26 ; Console . Write ( " STRNEWLINE Before ▁ Insertion : ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } n = insertSorted ( arr , n , key , capacity ) ; Console . Write ( " STRNEWLINE After ▁ Insertion : ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int binarySearch ( int [ ] arr , int low , int high , int key ) { if ( high < low ) return - 1 ; int mid = ( low + high ) / 2 ; if ( key == arr [ mid ] ) return mid ; if ( key > arr [ mid ] ) return binarySearch ( arr , ( mid + 1 ) , high , key ) ; return binarySearch ( arr , low , ( mid - 1 ) , key ) ; } static int deleteElement ( int [ ] arr , int n , int key ) { int pos = binarySearch ( arr , 0 , n - 1 , key ) ; if ( pos == - 1 ) { Console . WriteLine ( " Element ▁ not ▁ found " ) ; return n ; } int i ; for ( i = pos ; i < n - 1 ; i ++ ) arr [ i ] = arr [ i + 1 ] ; return n - 1 ; } public static void Main ( ) { int i ; int [ ] arr = { 10 , 20 , 30 , 40 , 50 } ; int n = arr . Length ; int key = 30 ; Console . Write ( " Array ▁ before ▁ deletion : STRNEWLINE " ) ; for ( i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; n = deleteElement ( arr , n , key ) ; Console . Write ( " STRNEWLINE STRNEWLINE Array ▁ after ▁ deletion : STRNEWLINE " ) ; for ( i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: i, mid
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 100 ; static int N = 5 ; static int M = 4 ; static int min ( int a , int b , int c ) { return Math . Min ( a , Math . Min ( b , c ) ) ; } static void solveQuery ( int n , int m , int [ , ] mat , int q , int [ ] a , int [ ] binary ) { int [ , ] dp = new int [ n , m ] ; int max = 1 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( i == 0 j == 0 ) dp [ i , j ] = 1 ; else if ( ( mat [ i , j ] == mat [ i - 1 , j ] ) && ( mat [ i , j ] == mat [ i , j - 1 ] ) && ( mat [ i , j ] == mat [ i - 1 , j - 1 ] ) ) { dp [ i , j ] = min ( dp [ i - 1 , j ] , dp [ i - 1 , j - 1 ] , dp [ i , j - 1 ] ) + 1 ; if ( max < dp [ i , j ] ) max = dp [ i , j ] ; } else dp [ i , j ] = 1 ; } } int [ ] freq0 = new int [ MAX ] ; int [ ] freq1 = new int [ MAX ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( mat [ i , j ] == 0 ) freq0 [ dp [ i , j ] ] ++ ; else freq1 [ dp [ i , j ] ] ++ ; } } for ( int i = max - 1 ; i >= 0 ; i -- ) { freq0 [ i ] += freq0 [ i + 1 ] ; freq1 [ i ] += freq1 [ i + 1 ] ; } for ( int i = 0 ; i < q ; i ++ ) { if ( binary [ i ] == 0 ) Console . WriteLine ( freq0 [ a [ i ] ] ) ; else Console . WriteLine ( freq1 [ a [ i ] ] ) ; } } public static void Main ( ) { int n = 5 , m = 4 ; int [ , ] mat = { { 0 , 0 , 1 , 1 } , { 0 , 0 , 1 , 0 } , { 0 , 1 , 1 , 1 } , { 1 , 1 , 1 , 1 } , { 0 , 1 , 1 , 1 } } ; int q = 2 ; int [ ] a = { 2 , 2 } ; int [ ] binary = { 1 , 0 } ; solveQuery ( n , m , mat , q , a , binary ) ; } }

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