dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static List < int > exit = new List < int > ( ) ; static int minTime ( int [ , ] meeting , int n , int [ ] entrance , int m , int p ) { int ans = int . MaxValue ; Array . Sort ( entrance ) ; exit . Sort ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int u = meeting [ i , 0 ] ; int v = meeting [ i , 1 ] ; int it1 = upper_bound ( entrance , 0 , entrance . Length , u ) ; int it2 = lowerBound ( exit , 0 , exit . Count , v ) ; int start = it1 - 1 ; int end = it2 ; if ( start >= 0 && start < m && end >= 0 && end < p ) ans = Math . Min ( ans , exit [ end ] - entrance [ start ] ) ; } return ans >= int . MaxValue ? - 1 : ans ; } static int upper_bound ( int [ ] a , int low , int high , int element ) { while ( low < high ) { int middle = low + ( high - low ) / 2 ; if ( a [ middle ] > element ) high = middle ; else low = middle + 1 ; } return low ; } static int lowerBound ( List < int > vec , int low , int high , int element ) { int [ ] array = new int [ vec . Count ] ; int k = 0 ; foreach ( int val in vec ) { array [ k ] = val ; k ++ ; } while ( low < high ) { int middle = low + ( high - low ) / 2 ; if ( element > array [ middle ] ) { low = middle + 1 ; } else { high = middle ; } } return low ; } public static void Main ( String [ ] args ) { int [ , ] meeting = { { 15 , 19 } , { 5 , 10 } , { 7 , 25 } } ; int [ ] entrance = { 4 , 13 , 25 , 2 } ; exit . Add ( 10 ) ; exit . Add ( 25 ) ; int n = meeting . GetLength ( 0 ) ; int m = entrance . Length ; int p = exit . Count ; Console . Write ( minTime ( meeting , n , entrance , m , p ) + " STRNEWLINE " ) ; } }

Index/key variables: end, k, middle, start
Accumulator variables: i, k
Iterator variables: i, val
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void splitArray ( int [ ] a , int n , int k ) { List < int > first = new List < int > ( ) ; List < int > second = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] <= k / 2 ) first . Add ( a [ i ] ) ; else second . Add ( a [ i ] ) ; } for ( int i = 0 ; i < first . Count ; i ++ ) { Console . Write ( first [ i ] + " ▁ " ) ; } Console . WriteLine ( ) ; for ( int i = 0 ; i < second . Count ; i ++ ) { Console . Write ( second [ i ] + " ▁ " ) ; } } public static void Main ( ) { int k = 5 ; int [ ] a = { 0 , 1 , 3 , 2 , 4 , 5 , 6 , 7 , 8 , 9 , 10 } ; int n = a . Length ; splitArray ( a , n , k ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int MAX = 1001 ; public static int [ ] sieve ( ) { int [ ] spf = new int [ MAX ] ; spf [ 0 ] = spf [ 1 ] = - 1 ; for ( int i = 2 ; i < MAX ; i ++ ) { spf [ i ] = i ; } for ( int i = 4 ; i < MAX ; i = i + 2 ) { spf [ i ] = 2 ; } for ( int i = 3 ; i * i < MAX ; i ++ ) { if ( spf [ i ] == i ) { for ( int j = i * i ; j < MAX ; j = j + i ) { if ( spf [ j ] == j ) { spf [ j ] = i ; } } } } return spf ; } public static int countFactors ( int [ ] spf , int num ) { int count = 0 ; while ( num > 1 ) { count ++ ; num = num / spf [ num ] ; } return count ; } public static int [ ] precalculateSum ( int [ ] spf ) { int [ ] sum = new int [ MAX ] ; sum [ 0 ] = 0 ; for ( int i = 1 ; i < MAX ; i ++ ) { int prime_factor = countFactors ( spf , i ) ; if ( spf [ prime_factor ] == prime_factor ) { sum [ i ] = sum [ i - 1 ] + 1 ; } else { sum [ i ] = sum [ i - 1 ] ; } } return sum ; } public static void Main ( String [ ] args ) { int [ ] spf = sieve ( ) ; int [ ] sum = precalculateSum ( spf ) ; int [ , ] Q = { { 4 , 8 } , { 30 , 32 } } ; for ( int i = 0 ; i < 2 ; i ++ ) { Console . Write ( ( sum [ Q [ i , 1 ] ] - sum [ Q [ i , 0 ] - 1 ] ) + " ▁ " ) ; } } }

Index/key variables: MAX, i, j, num, prime_factor
Accumulator variables: count, i
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int isPerfect ( int N ) { int sum = 1 ; for ( int i = 2 ; i < Math . Sqrt ( N ) ; i ++ ) { if ( N % i == 0 ) { if ( i == N / i ) { sum += i ; } else { sum += i + N / i ; } } } if ( sum == N && N != 1 ) return 1 ; return 0 ; } static int maxSum ( int [ ] arr , int N , int K ) { if ( N < K ) { Console . Write ( " Invalid " ) ; return - 1 ; } int res = 0 ; for ( int i = 0 ; i < K ; i ++ ) { res += arr [ i ] ; } int curr_sum = res ; for ( int i = K ; i < N ; i ++ ) { curr_sum += arr [ i ] - arr [ i - K ] ; res = Math . Max ( res , curr_sum ) ; } return res ; } static int max_PerfectNumbers ( int [ ] arr , int N , int K ) { for ( int i = 0 ; i < N ; i ++ ) { arr [ i ] = isPerfect ( arr [ i ] ) == 1 ? 1 : 0 ; } return maxSum ( arr , N , K ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 28 , 2 , 3 , 6 , 496 , 99 , 8128 , 24 } ; int K = 4 ; int N = arr . Length ; Console . Write ( max_PerfectNumbers ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: curr_sum, i, res, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void display ( int [ ] countLeftGreater , int N ) { for ( int i = 0 ; i < N ; i ++ ) { Console . Write ( countLeftGreater [ i ] + " ▁ " ) ; } } static void countGreater ( int [ ] arr , int N ) { List < int > St = new List < int > ( ) ; int [ ] countLeftGreater = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { St . Add ( arr [ i ] ) ; int it = 0 ; St . Sort ( ) ; foreach ( int itr in St ) { if ( arr [ i ] < itr ) { break ; } it ++ ; } countLeftGreater [ i ] = Math . Abs ( it - St . Count ) ; } display ( countLeftGreater , N ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 12 , 1 , 2 , 3 , 0 , 11 , 4 } ; int N = arr . Length ; countGreater ( arr , N ) ; } }

Index/key variables: N, i
Accumulator variables: i, it
Iterator variables: i, itr
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int minCost ( string A , string B ) { int n = A . Length ; int i = 0 ; int maxlen = 0 ; while ( i < n ) { int length = 0 ; for ( int j = 0 ; j < n ; ++ j ) { if ( A [ i ] == B [ j ] ) { ++ i ; ++ length ; if ( i == n ) break ; } } maxlen = Math . Max ( maxlen , length ) ; } return n - maxlen ; } public static void Main ( ) { string A = " edacb " ; string B = " abcde " ; Console . WriteLine ( minCost ( A , B ) ) ; } }

Index/key variables: i, j
Iterator variables: j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int lexicographicRank ( char [ ] s ) { int n = s . Length ; List < int > [ ] alphaIndex = new List < int > [ 26 ] ; for ( int i = 0 ; i < alphaIndex . Length ; i ++ ) alphaIndex [ i ] = new List < int > ( ) ; for ( int i = 0 ; i < s . Length ; i ++ ) { int x = s [ i ] - ' a ' ; alphaIndex [ x ] . Add ( i ) ; } int rank = 0 ; for ( int i = 0 ; i < 26 && ' a ' + i < s [ 0 ] ; i ++ ) { if ( alphaIndex [ i ] . Count > 0 ) { for ( int j = 0 ; j < alphaIndex [ i ] . Count ; j ++ ) { rank = rank + ( n - alphaIndex [ i ] [ j ] ) ; } } } List < String > str = new List < String > ( ) ; for ( int i = 0 ; i < alphaIndex [ s [ 0 ] - ' a ' ] . Count ; i ++ ) { String subString = " " ; int j = alphaIndex [ s [ 0 ] - ' a ' ] [ i ] ; for ( ; j < n ; j ++ ) { subString += ( s [ j ] ) ; str . Add ( subString ) ; } } str . Sort ( ) ; for ( int i = 0 ; i < str . Count ; i ++ ) { if ( ! str [ i ] . Equals ( String . Join ( " " , s ) ) ) { rank ++ ; } else { break ; } } return rank + 1 ; } public static void Main ( String [ ] args ) { String str = " enren " ; Console . Write ( lexicographicRank ( str . ToCharArray ( ) ) ) ; } }

Index/key variables: i, j, x
Accumulator variables: i, j, rank, subString
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int hIndex ( int [ ] citations , int n ) { int hindex = 0 ; int low = 0 , high = n - 1 ; while ( low <= high ) { int mid = ( low + high ) / 2 ; if ( citations [ mid ] >= ( mid + 1 ) ) { low = mid + 1 ; hindex = mid + 1 ; } else { high = mid - 1 ; } } Console . WriteLine ( hindex ) ; return hindex ; } public static void Main ( ) { int n = 5 ; int [ ] citations = { 5 , 3 , 3 , 2 , 2 } ; hIndex ( citations , n ) ; } }

Index/key variables: mid
Class/struct names: GFG
C# program:
using System ; class GFG { static bool checkEqual ( String [ ] arr , int N ) { int [ ] hash = new int [ 256 ] ; int M = arr [ 0 ] . Length ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { hash [ arr [ i ] [ j ] ] ++ ; } } for ( int i = 0 ; i < 256 ; i ++ ) { if ( hash [ i ] % N != 0 ) { return false ; } } return true ; } public static void Main ( String [ ] args ) { String [ ] arr = { " fdd " , " fhh " } ; int N = arr . Length ; if ( checkEqual ( arr , N ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int [ , ] dp = new int [ 100 , 100 ] ; static int maxweight ( int s , int e , Dictionary < int , int > pre ) { if ( s == e ) return 0 ; if ( dp [ s , e ] != - 1 ) return dp [ s , e ] ; int ans = 0 ; for ( int i = s ; i < e ; i ++ ) { int left = pre [ i ] - pre [ s - 1 ] ; int right = pre [ e ] - pre [ i ] ; if ( left < right ) ans = Math . Max ( ans , ( int ) ( left + maxweight ( s , i , pre ) ) ) ; if ( left == right ) ans = Math . Max ( ans , Math . Max ( left + maxweight ( s , i , pre ) , right + maxweight ( i + 1 , e , pre ) ) ) ; if ( left > right ) ans = Math . Max ( ans , right + maxweight ( i + 1 , e , pre ) ) ; dp [ s , e ] = ans ; } return dp [ s , e ] ; } static void maxSum ( int [ ] arr , int n ) { Dictionary < int , int > pre = new Dictionary < int , int > ( ) ; pre . Add ( - 1 , 0 ) ; pre . Add ( 0 , arr [ 0 ] ) ; for ( int i = 0 ; i < 100 ; i ++ ) { for ( int j = 0 ; j < 100 ; j ++ ) dp [ i , j ] = - 1 ; } for ( int i = 1 ; i < n ; i ++ ) pre . Add ( i , pre [ i - 1 ] + arr [ i ] ) ; Console . Write ( ( maxweight ( 0 , n - 1 , pre ) ) ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 6 , 2 , 3 , 4 , 5 , 5 } ; maxSum ( arr , 6 ) ; } }

Index/key variables: e, i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { class Node { public int data ; public Node left , right ; } ; static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . data = data ; temp . left = temp . right = null ; return temp ; } static List < int > storeLeaf ( Node root , List < int > arr ) { if ( root == null ) return arr ; if ( root . left == null && root . right == null ) { arr . Add ( root . data ) ; return arr ; } arr = storeLeaf ( root . left , arr ) ; arr = storeLeaf ( root . right , arr ) ; return arr ; } static void KSmallest ( Node root , int k ) { List < int > arr = new List < int > ( ) ; arr = storeLeaf ( root , arr ) ; arr . Sort ( ) ; for ( int i = 0 ; i < k ; i ++ ) { if ( i < arr . Count ) { Console . Write ( arr [ i ] + " ▁ " ) ; } else { break ; } } } public static void Main ( String [ ] args ) { Node root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . left . left = newNode ( 4 ) ; root . left . left . left = newNode ( 21 ) ; root . left . right = newNode ( 5 ) ; root . left . right . right = newNode ( 8 ) ; root . right = newNode ( 3 ) ; root . right . left = newNode ( 6 ) ; root . right . right = newNode ( 7 ) ; root . right . right . right = newNode ( 19 ) ; KSmallest ( root , 3 ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Node
C# program:
using System ; class GFG { static bool allCoprime ( int [ ] A , int n ) { bool all_coprime = true ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( gcd ( A [ i ] , A [ j ] ) != 1 ) { all_coprime = false ; break ; } } } return all_coprime ; } static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } public static void Main ( String [ ] args ) { int [ ] A = { 3 , 5 , 11 , 7 , 19 } ; int arr_size = A . Length ; if ( allCoprime ( A , arr_size ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: all_coprime
Class/struct names: GFG
C# program:
using System ; class GFG { static int smallestNum ( int n ) { double power = log2 ( 10 ) ; return ( int ) Math . Ceiling ( ( n - 1 ) * power ) ; } static double log2 ( int N ) { return ( Math . Log ( N ) / Math . Log ( 2 ) ) ; } public static void Main ( ) { int n = 4 ; Console . Write ( smallestNum ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static String findString ( String s , int k ) { int n = s . Length ; String ans = " ▁ " ; Stack < int > st = new Stack < int > ( ) ; bool [ ] vis = new bool [ n ] ; List < bool > vis ( n , false ) ; int count = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( s [ i ] == ' ( ' ) { st . Push ( i ) ; } if ( count < k && s [ i ] == ' ) ' ) { vis [ st . Peek ( ) ] = true ; st . Pop ( ) ; vis [ i ] = true ; count += 2 ; } } for ( int i = 0 ; i < n ; ++ i ) { if ( vis [ i ] == true ) { ans += s [ i ] ; } } return ans ; } public static void Main ( String [ ] args ) { String s = " ( ) ( ) ( ) " ; int K = 2 ; Console . Write ( findString ( s , K ) ) ; } }

Index/key variables: i, n
Accumulator variables: ans, count
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static Dictionary < int , Boolean > mp = new Dictionary < int , Boolean > ( ) ; static int max_v , rootIndex ; class Node { public int key ; public Node left , right ; } ; static Node newNode ( int key ) { Node temp = new Node ( ) ; temp . key = key ; temp . left = temp . right = null ; return ( temp ) ; } static List < int > findNodes ( Node root ) { if ( root == null ) { return new List < int > ( ) ; } List < int > left = findNodes ( root . left ) ; List < int > right = findNodes ( root . right ) ; List < int > combined = new List < int > ( ) ; int count = 0 ; for ( int i = 0 ; i < left . Count ; i ++ ) { if ( left [ i ] < root . key ) { count += 1 ; } combined . Add ( left [ i ] ) ; } for ( int i = 0 ; i < right . Count ; i ++ ) { if ( right [ i ] < root . key ) { count += 1 ; } combined . Add ( right [ i ] ) ; } combined . Add ( root . key ) ; if ( count > max_v ) { rootIndex = root . key ; max_v = count ; } return combined ; } public static void Main ( String [ ] args ) { Node root = newNode ( 3 ) ; root . left = newNode ( 4 ) ; root . right = newNode ( 6 ) ; root . right . left = newNode ( 4 ) ; root . right . right = newNode ( 5 ) ; root . left . left = newNode ( 10 ) ; root . left . right = newNode ( 2 ) ; max_v = 0 ; rootIndex = - 1 ; findNodes ( root ) ; Console . Write ( rootIndex ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG, Node
C# program:
using System ; class GFG { static int MaximumPath ( int [ , ] grid ) { int N = grid . GetLength ( 0 ) ; int M = grid . GetLength ( 1 ) ; int [ , ] sum = new int [ N + 1 , M + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 1 ; j <= M ; j ++ ) { sum [ i , j ] = Math . Max ( sum [ i - 1 , j ] , sum [ i , j - 1 ] ) + grid [ i - 1 , j - 1 ] ; } } return sum [ N , M ] ; } public static void Main ( String [ ] args ) { int [ , ] grid = { { 1 , 2 } , { 3 , 5 } } ; Console . Write ( MaximumPath ( grid ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int Maxcost ( string s , int [ ] cost ) { int maxcost = 0 ; int i = 0 ; while ( i < s . Length - 1 ) { if ( s [ i ] == s [ i + 1 ] ) { if ( cost [ i ] > cost [ i + 1 ] ) maxcost += cost [ i ] ; else { maxcost += cost [ i + 1 ] ; cost [ i + 1 ] = cost [ i ] ; } } i ++ ; } return maxcost ; } public static void Main ( string [ ] args ) { string s = " abaac " ; int [ ] cost = { 1 , 2 , 3 , 4 , 5 } ; Console . Write ( Maxcost ( s , cost ) ) ; } }

Index/key variables: i
Accumulator variables: i, maxcost
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static Dictionary < Tuple < int , int > , int > dp = new Dictionary < Tuple < int , int > , int > ( ) ; static int countMagicNumbers ( int idx , int sum , int [ ] a , int n , int m , int l , int r ) { if ( idx == n ) { int Temp = sum % m ; if ( Temp == l || Temp == r || ( Temp > l && Temp < r ) ) return dp [ new Tuple < int , int > ( idx , sum ) ] = 1 ; else return dp [ new Tuple < int , int > ( idx , sum ) ] = 0 ; } Tuple < int , int > curr = new Tuple < int , int > ( idx , sum ) ; if ( dp . ContainsKey ( curr ) ) return dp [ curr ] ; int ls = countMagicNumbers ( idx + 1 , sum + a [ idx ] , a , n , m , l , r ) ; int rs = countMagicNumbers ( idx + 1 , sum + ( a [ idx ] - 1 ) , a , n , m , l , r ) ; int temp1 = Math . Max ( ls , rs ) ; int temp = sum % m ; if ( ( temp == l || temp == r || ( temp > l && temp < r ) ) && idx != 0 ) { temp1 += 1 ; } return dp [ new Tuple < int , int > ( idx , sum ) ] = temp1 ; } static void Main ( ) { int N = 5 , M = 22 , L = 14 , R = 16 ; int [ ] arr = { 17 , 11 , 10 , 8 , 15 } ; Console . Write ( countMagicNumbers ( 0 , 0 , arr , N , M , L , R ) ) ; } }

Index/key variables: curr, idx
Accumulator variables: temp1
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool reachesBottom ( int [ , ] a , int n , int m ) { Queue < int [ ] > q = new Queue < int [ ] > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( a [ i , j ] == 1 ) { q . Enqueue ( new int [ ] { i , j , 1 } ) ; } else if ( a [ i , j ] == 2 ) { q . Enqueue ( new int [ ] { i , j , 2 } ) ; } a [ i , j ] = 0 ; } } int [ ] dx = { - 1 , 0 , 1 , 0 } ; int [ ] dy = { 0 , 1 , 0 , - 1 } ; while ( q . Count != 0 ) { int [ ] front = q . Peek ( ) ; q . Dequeue ( ) ; int i = front [ 0 ] , j = front [ 1 ] ; int t = front [ 2 ] ; if ( a [ i , j ] == 1 ) continue ; a [ i , j ] = 1 ; if ( t == 1 && ( i == n - 1 && j == m - 1 ) ) { return true ; } for ( int d = 0 ; d < 4 ; d ++ ) { int ni = i + dx [ d ] ; int nj = j + dy [ d ] ; if ( ni >= 0 && ni < n && nj >= 0 && nj < m ) { q . Enqueue ( new int [ ] { ni , nj , t } ) ; } } } return false ; } public static void Main ( String [ ] args ) { int [ , ] matrix = { { 0 , 2 , 0 } , { 0 , 1 , 0 } , { 0 , 2 , 0 } } ; if ( reachesBottom ( matrix , 3 , 3 ) ) { Console . Write ( " YES " ) ; } else { Console . Write ( " NO " ) ; } } }

Index/key variables: d
Accumulator variables: d, i, j
Iterator variables: d, i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static int [ , ] matrixMinimum ( int [ , ] nums , int K ) { int N = nums . GetLength ( 0 ) ; int M = nums . GetLength ( 1 ) ; int [ , ] res = new int [ N - K + 1 , M - K + 1 ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M - K + 1 ; j ++ ) { int min = int . MaxValue ; for ( int k = j ; k < j + K ; k ++ ) { min = Math . Min ( min , nums [ i , k ] ) ; } nums [ i , j ] = min ; } } for ( int j = 0 ; j < M ; j ++ ) { for ( int i = 0 ; i < N - K + 1 ; i ++ ) { int min = int . MaxValue ; for ( int k = i ; k < i + K ; k ++ ) { min = Math . Min ( min , nums [ k , j ] ) ; } nums [ i , j ] = min ; } } for ( int i = 0 ; i < N - K + 1 ; i ++ ) for ( int j = 0 ; j < M - K + 1 ; j ++ ) res [ i , j ] = nums [ i , j ] ; return res ; } public static void smallestinKsubmatrices ( int [ , ] arr , int K ) { int [ , ] res = matrixMinimum ( arr , K ) ; for ( int i = 0 ; i < res . GetLength ( 0 ) ; i ++ ) { for ( int j = 0 ; j < res . GetLength ( 1 ) ; j ++ ) { Console . Write ( res [ i , j ] + " ▁ " ) ; } Console . WriteLine ( ) ; } } public static void Main ( String [ ] args ) { int [ , ] arr = { { - 1 , 5 , 4 , 1 , - 3 } , { 4 , 3 , 1 , 1 , 6 } , { 2 , - 2 , 5 , 3 , 1 } , { 8 , 5 , 1 , 9 , - 4 } , { 12 , 3 , 5 , 8 , 1 } } ; int K = 3 ; smallestinKsubmatrices ( arr , K ) ; } }

Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static char find_kth_largest ( char [ ] str , int k ) { Array . Sort ( str ) ; reverse ( str ) ; return str [ k - 1 ] ; } static char [ ] reverse ( char [ ] a ) { int i , n = a . Length ; char t ; for ( i = 0 ; i < n / 2 ; i ++ ) { t = a [ i ] ; a [ i ] = a [ n - i - 1 ] ; a [ n - i - 1 ] = t ; } return a ; } static char printchar ( String str , int l , int r , int k ) { l = l - 1 ; r = r - 1 ; String temp = str . Substring ( l , r - l + 1 ) ; char ans = find_kth_largest ( temp . ToCharArray ( ) , k ) ; return ans ; } static void updateString ( char [ ] str , int pos , char s ) { int index = pos - 1 ; char c = s ; str [ index ] = c ; } public static void Main ( String [ ] args ) { String str = " abcddef " ; Console . Write ( printchar ( str , 1 , 2 , 2 ) + " STRNEWLINE " ) ; updateString ( str . ToCharArray ( ) , 4 , ' g ' ) ; Console . Write ( printchar ( str , 1 , 5 , 4 ) + " STRNEWLINE " ) ; } }

Index/key variables: i, index
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minDiffSubArray ( int [ ] arr , int n ) { int total_sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) total_sum += arr [ i ] ; int prefix_sum = 0 ; int minDiff = int . MaxValue ; for ( int i = 0 ; i < n - 1 ; i ++ ) { prefix_sum += arr [ i ] ; int diff = Math . Abs ( ( total_sum - prefix_sum ) - prefix_sum ) ; if ( diff < minDiff ) minDiff = diff ; } return minDiff ; } public static void Main ( String [ ] args ) { int [ ] arr = { 7 , 9 , 5 , 10 } ; int n = arr . Length ; Console . WriteLine ( minDiffSubArray ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, prefix_sum, total_sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int CtSubarr ( int [ ] arr , int N , int K ) { HashSet < int > st = new HashSet < int > ( ) ; int prefixSum = 0 ; st . Add ( prefixSum ) ; int res = 0 ; for ( int i = 0 ; i < N ; i ++ ) { prefixSum += arr [ i ] ; if ( st . Contains ( prefixSum - K ) ) { res += 1 ; prefixSum = 0 ; st . Clear ( ) ; st . Add ( 0 ) ; } st . Add ( prefixSum ) ; } return res ; } public static void Main ( String [ ] args ) { int [ ] arr = { - 2 , 6 , 6 , 3 , 5 , 4 , 1 , 2 , 8 } ; int N = arr . Length ; int K = 10 ; Console . WriteLine ( CtSubarr ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: i, prefixSum, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool is_prime ( int n ) { if ( n <= 1 ) return false ; for ( int i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) return false ; } return true ; } static int count_prime_subarrays ( int [ ] ar , int n ) { int ans = 0 ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( is_prime ( ar [ i ] ) ) count ++ ; else { if ( count != 0 ) { ans += count * ( count + 1 ) / 2 ; count = 0 ; } } } if ( count != 0 ) ans += count * ( count + 1 ) / 2 ; return ans ; } public static void Main ( String [ ] args ) { int N = 10 ; int [ ] ar = { 2 , 3 , 5 , 6 , 7 , 11 , 3 , 5 , 9 , 3 } ; Console . Write ( count_prime_subarrays ( ar , N ) ) ; } }

Index/key variables: i
Accumulator variables: ans, count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minSteps ( int [ ] arr , int n , int k ) { int i , cnt = 0 ; int flag ; if ( k == 1 ) flag = 0 ; else flag = 1 ; for ( i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == flag ) { cnt ++ ; flag = ( flag + 1 ) % 2 ; } } return cnt ; } public static void Main ( ) { int [ ] arr = { 1 , 0 , 1 , 0 , 0 , 1 , 1 , 1 } ; int n = arr . Length ; int k = 1 ; Console . Write ( minSteps ( arr , n , k ) ) ; } }

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