dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int findMinDif ( int [ ] arr , int N ) { Array . Sort ( arr ) ; return ( arr [ N - 1 ] - arr [ N - 2 ] ) ; } public static void Main ( ) { int [ ] arr = { 7 , 9 , 5 , 10 } ; int N = arr . Length ; Console . Write ( findMinDif ( arr , N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int partition ( int [ ] arr , int l , int h ) { int pivot = arr [ l ] ; int i = l + 1 ; int j = h ; while ( i <= j ) { while ( i <= h && arr [ i ] < pivot ) { i ++ ; } while ( j > l && arr [ j ] > pivot ) { j -- ; } if ( i < j ) { int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; i ++ ; j -- ; } else i ++ ; } arr [ l ] = arr [ j ] ; arr [ j ] = pivot ; return j ; } static void sortArray ( int [ ] arr , int l , int h ) { if ( l >= h ) return ; int pivot = partition ( arr , l , h ) ; sortArray ( arr , l , pivot - 1 ) ; sortArray ( arr , pivot + 1 , h ) ; } static int findMaxIntervals ( int [ ] start , int [ ] end , int n , int R ) { int ans = 0 ; int prev = 0 ; int currActive = 0 ; int i = 0 ; int j = 0 ; if ( start [ 0 ] > 0 ) ans ++ ; while ( i < n && j < n ) { if ( start [ i ] < end [ j ] ) { i ++ ; currActive ++ ; } else if ( start [ i ] > end [ j ] ) { j ++ ; currActive -- ; } else { i ++ ; j ++ ; } if ( currActive == 0 ) { ans ++ ; } } if ( end [ n - 1 ] < R ) ans ++ ; return ans ; } public static void Main ( ) { int R , N ; R = 10 ; N = 3 ; int [ ] start = new int [ ] { 2 , 5 , 8 } ; int [ ] end = new int [ ] { 3 , 9 , 10 } ; sortArray ( start , 0 , N - 1 ) ; sortArray ( end , 0 , N - 1 ) ; Console . Write ( findMaxIntervals ( start , end , N , R ) ) ; } }

Index/key variables: i, j, l
Accumulator variables: ans, currActive, i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static int number ( int [ ] a , int n , int p , int k ) { Array . Sort ( a ) ; int [ ] pre = new int [ n ] ; int i , ans = 0 ; pre [ 0 ] = a [ 0 ] ; if ( pre [ 0 ] <= p ) ans = 1 ; for ( i = 1 ; i < k - 1 ; i ++ ) { pre [ i ] = pre [ i - 1 ] + a [ i ] ; if ( pre [ i ] <= p ) ans = i + 1 ; } pre [ k - 1 ] = a [ k - 1 ] ; for ( i = k - 1 ; i < n ; i ++ ) { if ( i >= k ) { pre [ i ] += pre [ i - k ] + a [ i ] ; } if ( pre [ i ] <= p ) ans = i + 1 ; } return ans ; } static public void Main ( ) { int n = 5 ; int [ ] arr = { 2 , 4 , 3 , 5 , 7 } ; int p = 11 ; int k = 2 ; Console . WriteLine ( number ( arr , n , p , k ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; using System . Linq ; class GFG { static void sieveOfEratosthenes ( bool [ ] prime , int n ) { prime [ 0 ] = prime [ 1 ] = false ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= n ; i += p ) prime [ i ] = false ; } } } static void sortSpecialPrimes ( int [ ] arr , int n ) { int maxVal = arr . Max ( ) ; bool [ ] prime = new bool [ maxVal + 1 ] ; for ( int i = 0 ; i < prime . Length ; i ++ ) prime [ i ] = true ; sieveOfEratosthenes ( prime , maxVal ) ; List < int > list = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( prime [ arr [ i ] ] && prime [ arr [ i ] - 2 ] ) { list . Add ( arr [ i ] ) ; arr [ i ] = - 1 ; } } list . Sort ( ) ; int j = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == - 1 ) Console . Write ( list [ j ++ ] + " ▁ " ) ; else Console . Write ( arr [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 31 , 5 , 2 , 1 , 7 } ; int n = arr . Length ; sortSpecialPrimes ( arr , n ) ; } }

Index/key variables: i, p
Accumulator variables: i, j, p
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxProfit ( int [ ] arr ) { Array . Sort ( arr ) ; Array . Reverse ( arr ) ; int ans = 0 ; for ( int i = 0 ; i < arr . Length ; i ++ ) { if ( ( arr [ i ] - ( 1 * i ) ) > 0 ) ans += ( arr [ i ] - ( 1 * i ) ) ; if ( ( arr [ i ] - ( 1 * i ) ) == 0 ) break ; } return ans ; } static public void Main ( ) { int [ ] arr = { 6 , 6 , 6 } ; Console . Write ( maxProfit ( arr ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void check_vector ( int [ ] A , int n , int [ ] p ) { int [ ] pos = new int [ A . Length ] ; for ( int i = 0 ; i < p . Length ; i ++ ) { pos [ p [ i ] - 1 ] = 1 ; } int flag = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( pos [ i ] == 0 ) continue ; int j = i ; while ( j < n && pos [ j ] != 0 ) ++ j ; Array . Sort ( A , i , j + 1 ) ; i = j ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( A [ i ] > A [ i + 1 ] ) { flag = 0 ; break ; } } if ( flag == 1 ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } public static void Main ( ) { int [ ] A = { 3 , 2 , 1 } ; int [ ] p = { 1 , 2 } ; check_vector ( A , A . Length , p ) ; } }

Index/key variables: i, j
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void sortDiff ( List < int > arr , int n ) { arr . Sort ( ) ; List < int > Out = new List < int > ( ) ; while ( n > 0 ) { Out . Add ( arr [ n / 2 ] ) ; arr . RemoveAt ( n / 2 ) ; n = n - 1 ; } foreach ( int i in Out ) Console . Write ( i + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] a = { 8 , 1 , 2 , 3 , 0 } ; List < int > arr = new List < int > ( a ) ; int n = 5 ; sortDiff ( arr , n ) ; } }

Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void minimumCost ( int [ ] arr , int N , int M ) { Array . Sort ( arr ) ; int [ ] pref = new int [ N ] ; pref [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { pref [ i ] = arr [ i ] + pref [ i - 1 ] ; } for ( int i = M ; i < N ; i ++ ) { pref [ i ] += pref [ i - M ] ; } for ( int i = 0 ; i < N ; i ++ ) { Console . Write ( pref [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 6 , 19 , 3 , 4 , 4 , 2 , 6 , 7 , 8 } ; int M = 2 ; int N = arr . Length ; minimumCost ( arr , N , M ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int uniqueSum ( int [ ] A , int [ , ] R , int N , int M ) { for ( int i = 0 ; i < M ; ++ i ) { int l = R [ i , 0 ] , r = R [ i , 1 ] + 1 ; l -- ; r -- ; A [ l ] ++ ; if ( r < N ) A [ r ] -- ; } for ( int i = 1 ; i < N ; ++ i ) { A [ i ] += A [ i - 1 ] ; } int ans = 0 ; HashSet < int > s = new HashSet < int > ( ) ; for ( int i = 0 ; i < N ; ++ i ) { if ( ! s . Contains ( A [ i ] ) ) ans += A [ i ] ; s . Add ( A [ i ] ) ; } return ans ; } public static void Main ( String [ ] args ) { int [ ] A = { 0 , 0 , 0 , 0 , 0 , 0 } ; int [ , ] R = { { 1 , 3 } , { 4 , 6 } , { 3 , 4 } , { 3 , 3 } } ; int N = A . Length ; int M = R . GetLength ( 0 ) ; Console . Write ( uniqueSum ( A , R , N , M ) ) ; } }

Index/key variables: i, l, r
Accumulator variables: ans, l, r
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void kthpair ( int n , int k , int [ ] arr ) { int i , t = 0 ; Array . Sort ( arr ) ; -- k ; for ( i = 0 ; i < n ; i += t ) { for ( t = 1 ; arr [ i ] == arr [ i + t ] ; ++ t ) ; if ( t * n > k ) break ; k = k - t * n ; } Console . Write ( arr [ i ] + " ▁ " + arr [ k / t ] ) ; } static public void Main ( ) { int n = 3 , k = 2 ; int [ ] arr = { 3 , 1 , 5 } ; kthpair ( n , k , arr ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i, t
Class/struct names: GFG
C# program:
using System ; class GFG { static int minOperations ( String s ) { int [ ] freq = new int [ 26 ] ; int n = s . Length ; for ( int i = 0 ; i < n ; i ++ ) { freq [ s [ i ] - ' A ' ] ++ ; } Array . Sort ( freq ) ; Array . Reverse ( freq ) ; int answer = n ; for ( int i = 1 ; i <= 26 ; i ++ ) { if ( n % i == 0 ) { int x = n / i ; int y = 0 ; for ( int j = 0 ; j < i ; j ++ ) { y += Math . Min ( freq [ j ] , x ) ; } answer = Math . Min ( answer , n - y ) ; } } return answer ; } public static void Main ( String [ ] args ) { String s = " BBC " ; Console . Write ( minOperations ( s ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, y
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static bool fun ( int [ ] arr , int n , int k ) { List < int > v = new List < int > ( ) ; for ( int i = 0 ; i < k ; i ++ ) { for ( int j = i ; j < n ; j += k ) { v . Add ( arr [ j ] ) ; } v . Sort ( ) ; int x = 0 ; for ( int j = i ; j < n ; j += k ) { arr [ j ] = v [ x ] ; x ++ ; } v . Clear ( ) ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i ] > arr [ i + 1 ] ) { return false ; } } return true ; } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , 2 , 3 , 7 , 6 } ; int K = 2 ; int n = arr . Length ; if ( fun ( arr , n , K ) ) { Console . WriteLine ( " yes " ) ; } else { Console . WriteLine ( " no " ) ; } } }

Index/key variables: i, j, x
Accumulator variables: i, j, x
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void sortedAdjacentDifferences ( int [ ] arr , int n ) { int [ ] ans = new int [ n ] ; Array . Sort ( arr ) ; int l = 0 , r = n - 1 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( i % 2 != 0 ) { ans [ i ] = arr [ l ] ; l ++ ; } else { ans [ i ] = arr [ r ] ; r -- ; } } for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( ans [ i ] + " ▁ " ) ; } } public static void Main ( ) { int [ ] arr = { 5 , - 2 , 4 , 8 , 6 , 4 , 5 } ; int n = arr . Length ; sortedAdjacentDifferences ( arr , n ) ; } }

Index/key variables: i, l, n, r
Accumulator variables: i, l, r
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int get_permutation ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int result = 0 ; for ( int i = 0 ; i < n ; i ++ ) { result += Math . Abs ( arr [ i ] - ( i + 1 ) ) ; } return result ; } public static void Main ( ) { int [ ] arr = { 0 , 2 , 3 , 4 , 1 , 6 , 8 , 9 } ; int n = arr . Length ; Console . Write ( get_permutation ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, result
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Linq ; class GFG { static int [ , ] dp = new int [ 1000 , 1000 ] ; static int minimumIncDec ( int [ ] arr , int N , int maxE , int minE ) { if ( N == 0 ) { return 0 ; } if ( dp [ N , maxE ] != 0 ) return dp [ N , maxE ] ; int ans = int . MaxValue ; for ( int k = minE ; k <= maxE ; k ++ ) { int x = minimumIncDec ( arr , N - 1 , k , minE ) ; ans = Math . Min ( ans , x + Math . Abs ( arr [ N - 1 ] - k ) ) ; } dp [ N , maxE ] = ans ; return dp [ N , maxE ] ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 4 , 3 , 2 , 1 } ; int N = arr . Length ; int minE = arr . Min ( ) ; int maxE = arr . Max ( ) ; Console . Write ( minimumIncDec ( arr , N , maxE , minE ) ) ; } }

Accumulator variables: k
Iterator variables: k
Class/struct names: GFG
C# program:
using System ; class GFG { static void sortDiagonal ( int [ , ] a , int M , int N ) { for ( int i = 0 ; i < M ; i ++ ) { int sm = a [ i , i ] ; int pos = i ; for ( int j = i + 1 ; j < N ; j ++ ) { if ( sm > a [ j , j ] ) { sm = a [ j , j ] ; pos = j ; } } swap ( a , i , i , pos , pos ) ; } for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) Console . Write ( a [ i , j ] + " ▁ " ) ; Console . WriteLine ( ) ; } } static void swap ( int [ , ] a , int i , int i2 , int pos , int pos2 ) { int temp = a [ i , i2 ] ; a [ i , i2 ] = a [ pos , pos2 ] ; a [ pos , pos2 ] = temp ; } public static void Main ( String [ ] args ) { int [ , ] a = { { 4 , 2 } , { 3 , 1 } } ; sortDiagonal ( a , 2 , 2 ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int make_permutation ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) ans += Math . Abs ( i + 1 - arr [ i ] ) ; return ans ; } public static void Main ( string [ ] args ) { int [ ] arr = { 5 , 3 , 8 , 1 , 1 } ; int n = arr . Length ; Console . WriteLine ( make_permutation ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int maxSum ( int [ , ] V , int n , int m ) { int ans = 0 ; for ( int i = n - 2 ; i >= 0 ; -- i ) { List < Tuple < int , int > > aux = new List < Tuple < int , int > > ( ) ; for ( int j = 0 ; j < m ; ++ j ) { aux . Add ( new Tuple < int , int > ( V [ i + 1 , j ] , j ) ) ; } aux . Sort ( ) ; aux . Reverse ( ) ; for ( int j = 0 ; j < m ; ++ j ) { for ( int k = 0 ; k < m ; ++ k ) { if ( aux [ k ] . Item2 - j == 0 || Math . Abs ( aux [ k ] . Item2 - j ) > 1 ) { V [ i , j ] += aux [ k ] . Item1 ; break ; } } } } for ( int i = 0 ; i < m ; ++ i ) { ans = Math . Max ( ans , V [ 0 , i ] ) ; } return ans ; } static void Main ( ) { int [ , ] V = { { 1 , 2 , 3 , 4 } , { 8 , 7 , 6 , 5 } , { 10 , 11 , 12 , 13 } } ; int n = V . GetLength ( 0 ) ; int m = V . GetLength ( 1 ) ; Console . WriteLine ( maxSum ( V , n , m ) ) ; } }

Index/key variables: k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int minimumProduct ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int product = 1 ; for ( int i = 0 ; i < n ; i += 2 ) { product *= ( arr [ i ] + arr [ i + 1 ] ) ; } return product ; } static void Main ( ) { int [ ] arr = new int [ ] { 1 , 6 , 3 , 1 , 7 , 8 } ; int n = arr . Length ; Console . Write ( minimumProduct ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, product
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool checkIsAP ( double [ ] arr , int n ) { if ( n == 1 ) return true ; Array . Sort ( arr ) ; double d = arr [ 1 ] - arr [ 0 ] ; for ( int i = 2 ; i < n ; i ++ ) { if ( arr [ i ] - arr [ i - 1 ] != d ) { return false ; } } return true ; } static bool checkIsGP ( double [ ] arr , int n ) { if ( n == 1 ) return true ; Array . Sort ( arr ) ; double r = arr [ 1 ] / arr [ 0 ] ; for ( int i = 2 ; i < n ; i ++ ) { if ( arr [ i ] / arr [ i - 1 ] != r ) return false ; } return true ; } static bool checkIsHP ( double [ ] arr , int n ) { if ( n == 1 ) { return true ; } double [ ] rec = new double [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { rec [ i ] = ( ( 1 / arr [ i ] ) ) ; } if ( checkIsAP ( rec , n ) ) return true ; else return false ; } public static void Main ( String [ ] args ) { double [ ] arr = { 1.0 / 5.0 , 1.0 / 10.0 , 1.0 / 15.0 , 1.0 / 20.0 } ; int n = arr . Length ; int flag = 0 ; if ( checkIsAP ( arr , n ) ) { Console . Write ( " Yes , ▁ An ▁ AP ▁ can ▁ be ▁ formed " + " STRNEWLINE " ) ; flag = 1 ; } if ( checkIsGP ( arr , n ) ) { Console . Write ( " Yes , ▁ A ▁ GP ▁ can ▁ be ▁ formed " + " STRNEWLINE " ) ; flag = 1 ; } if ( checkIsHP ( arr , n ) ) { Console . Write ( " Yes , ▁ A ▁ HP ▁ can ▁ be ▁ formed " + " STRNEWLINE " ) ; flag = 1 ; } else if ( flag == 0 ) { Console . Write ( " No " ) ; } } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int reversDigits ( int num ) { int rev_num = 0 ; while ( num > 0 ) { rev_num = rev_num * 10 + num % 10 ; num = num / 10 ; } return rev_num ; } static void sortArr ( int [ ] arr , int n ) { List < Tuple < int , int > > vp = new List < Tuple < int , int > > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { vp . Add ( new Tuple < int , int > ( reversDigits ( arr [ i ] ) , arr [ i ] ) ) ; } vp . Sort ( ) ; for ( int i = 0 ; i < vp . Count ; i ++ ) Console . Write ( vp [ i ] . Item2 + " ▁ " ) ; } static void Main ( ) { int [ ] arr = { 12 , 10 , 102 , 31 , 15 } ; int n = arr . Length ; sortArr ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void sortMat ( int [ , ] data , int row , int col ) { int size = row * col ; for ( int i = 0 ; i < size ; i ++ ) { for ( int j = 0 ; j < size - 1 ; j ++ ) { if ( data [ j / col , j % col ] > data [ ( j + 1 ) / col , ( j + 1 ) % col ] ) { int temp = data [ j / col , j % col ] ; data [ j / col , j % col ] = data [ ( j + 1 ) / col , ( j + 1 ) % col ] ; data [ ( j + 1 ) / col , ( j + 1 ) % col ] = temp ; } } } } static void printMat ( int [ , ] mat , int row , int col ) { for ( int i = 0 ; i < row ; i ++ ) { for ( int j = 0 ; j < col ; j ++ ) { Console . Write ( mat [ i , j ] + " ▁ " ) ; } Console . WriteLine ( ) ; } } public static void Main ( String [ ] args ) { int [ , ] mat = { { 5 , 4 , 7 } , { 1 , 3 , 8 } , { 2 , 9 , 6 } } ; int row = mat . GetLength ( 0 ) ; int col = mat . GetLength ( 1 ) ; sortMat ( mat , row , col ) ; printMat ( mat , row , col ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int minimiseMedian ( int [ ] arr , int n ) { Array . Sort ( arr ) ; return Math . Abs ( arr [ n / 2 ] - arr [ ( n / 2 ) - 1 ] ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 15 , 25 , 35 , 50 } ; int n = arr . Length ; Console . WriteLine ( minimiseMedian ( arr , n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static bool canBeEqual ( int a , int b , int c , int k ) { int [ ] arr = new int [ 3 ] ; arr [ 0 ] = a ; arr [ 1 ] = b ; arr [ 2 ] = c ; Array . Sort ( arr ) ; int diff = 2 * arr [ 2 ] - arr [ 1 ] - arr [ 0 ] ; k = k - diff ; if ( k < 0 k % 3 != 0 ) return false ; return true ; } public static void Main ( String [ ] args ) { int a1 = 6 , b1 = 3 , c1 = 2 , k1 = 7 ; if ( canBeEqual ( a1 , b1 , c1 , k1 ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] orgazineInOrder ( int [ ] vec , int [ ] op , int n ) { int [ ] result = new int [ n ] ; Array . Sort ( vec ) ; int i = 0 , j = n - 1 , k = 0 ; while ( i <= j && k <= n - 2 ) { if ( op [ k ] == ' < ' ) { result [ k ] = vec [ i ++ ] ; } else { result [ k ] = vec [ j -- ] ; } k ++ ; } result [ n - 1 ] = vec [ i ] ; return result ; } public static void Main ( ) { int [ ] vec = { 8 , 2 , 7 , 1 , 5 , 9 } ; int [ ] op = { ' > ' , ' > ' , ' < ' , ' > ' , ' < ' } ; int [ ] result = orgazineInOrder ( vec , op , vec . Length ) ; for ( int i = 0 ; i < result . Length ; i ++ ) { Console . Write ( result [ i ] + " ▁ " ) ; } } }

Index/key variables: i, k, n
Accumulator variables: i, j, k
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findSum ( int [ ] arr , int n , int k ) { int ans = arr [ n - k - 1 ] - arr [ 0 ] ; for ( int i = 1 ; i <= k ; i ++ ) { ans = Math . Min ( arr [ n - 1 - ( k - i ) ] - arr [ i ] , ans ) ; } return ans ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 100 , 120 , 140 } ; int k = 2 ; int n = arr . Length ; Console . WriteLine ( findSum ( arr , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMin ( int [ ] arr , int n ) { int ans = 1 ; for ( int i = 0 ; i < n ; i ++ ) { int j = i + 1 ; while ( j < n && arr [ j ] >= arr [ j - 1 ] ) j ++ ; ans = Math . Max ( ans , j - i ) ; i = j - 1 ; } return n - ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 2 , 1 } ; int n = arr . Length ; Console . WriteLine ( findMin ( arr , n ) ) ; } }

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countSubSeq ( int [ ] a , int n , int k ) { Array . Sort ( a ) ; List < int > arr = new List < int > ( ) ; int count , x ; for ( int i = 0 ; i < n ; ) { count = 1 ; x = a [ i ] ; i ++ ; while ( i < n && a [ i ] == x ) { count ++ ; i ++ ; } arr . Add ( count ) ; } int m = arr . Count ; n = Math . Min ( m , k ) ; count = 1 ; int [ , ] dp = new int [ n + 1 , m + 1 ] ; for ( int i = 0 ; i <= m ; i ++ ) dp [ 0 , i ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = m ; j >= 0 ; j -- ) { if ( j > m - i ) dp [ i , j ] = 0 ; else { dp [ i , j ] = dp [ i , j + 1 ] + arr [ j ] * dp [ i - 1 , j + 1 ] ; } } count = count + dp [ i , 0 ] ; } return count ; } public static void Main ( String [ ] args ) { int [ ] a = { 2 , 2 , 3 , 3 , 5 } ; int n = a . Length ; int k = 3 ; Console . WriteLine ( countSubSeq ( a , n , k ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int countUnvisited ( int n , int m ) { int X = ( m * n ) - m - n ; Queue < int > queue = new Queue < int > ( ) ; queue . Enqueue ( X ) ; int count = 0 ; while ( queue . Count != 0 ) { int curr = queue . Dequeue ( ) ; count ++ ; if ( curr - m > 0 ) queue . Enqueue ( curr - m ) ; if ( curr - n > 0 ) queue . Enqueue ( curr - n ) ; } return count ; } public static void Main ( String [ ] args ) { int n = 2 , m = 5 ; Console . WriteLine ( countUnvisited ( n , m ) ) ; } }

Accumulator variables: count
Class/struct names: GFG
C# program:
using System ; class GFG { static string partOdd ( string s ) { string st = " " ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( i % 2 != 0 ) st += s [ i ] ; } return st ; } static string partEven ( string str ) { string s = " " ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( i % 2 == 0 ) s += str [ i ] ; } return s ; } static bool canBeMadeEqual ( string s1 , string s2 ) { char [ ] even1 = partEven ( s1 ) . ToCharArray ( ) ; char [ ] even2 = partEven ( s2 ) . ToCharArray ( ) ; char [ ] odd1 = partOdd ( s1 ) . ToCharArray ( ) ; char [ ] odd2 = partOdd ( s2 ) . ToCharArray ( ) ; Array . Sort ( even1 ) ; Array . Sort ( even2 ) ; Array . Sort ( odd1 ) ; Array . Sort ( odd2 ) ; string even_s1 = new string ( even1 ) ; string even_s2 = new string ( even2 ) ; string odd_s1 = new string ( odd1 ) ; string odd_s2 = new string ( odd2 ) ; if ( even_s1 . Equals ( even_s2 ) && odd_s1 . Equals ( odd_s2 ) ) return true ; return false ; } public static void Main ( ) { string s1 = " cdab " ; string s2 = " abcd " ; if ( canBeMadeEqual ( s1 , s2 ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i, s, st
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static void sortStack ( Stack input , int k ) { Stack tmpStack = new Stack ( ) ; while ( input . Count != 0 ) { int tmp = ( int ) input . Peek ( ) ; input . Pop ( ) ; while ( tmpStack . Count != 0 ) { int tmpStackMod = ( int ) tmpStack . Peek ( ) % k ; int tmpMod = tmp % k ; if ( ( tmpStackMod > tmpMod ) || ( tmpStackMod == tmpMod && ( int ) tmpStack . Peek ( ) > tmp ) ) { input . Push ( ( int ) tmpStack . Peek ( ) ) ; tmpStack . Pop ( ) ; } else break ; } tmpStack . Push ( tmp ) ; } while ( tmpStack . Count != 0 ) { input . Push ( ( int ) tmpStack . Peek ( ) ) ; tmpStack . Pop ( ) ; } while ( input . Count != 0 ) { Console . Write ( ( int ) input . Peek ( ) + " ▁ " ) ; input . Pop ( ) ; } } public static void Main ( string [ ] args ) { Stack input = new Stack ( ) ; input . Push ( 10 ) ; input . Push ( 3 ) ; input . Push ( 2 ) ; input . Push ( 6 ) ; input . Push ( 12 ) ; int k = 4 ; sortStack ( input , k ) ; } }

Class/struct names: GFG