dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static void minimumRange ( int [ ] arr , int N , int K ) { if ( K >= N ) { Console . Write ( 0 ) ; return ; } Array . Sort ( arr ) ; int left = 0 , right = N - 1 , i ; for ( i = 0 ; i < K ; i ++ ) { if ( arr [ right - 1 ] - arr [ left ] < arr [ right ] - arr [ left + 1 ] ) right -- ; else left ++ ; } Console . Write ( arr [ right ] - arr [ left ] ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 10 , 12 , 14 , 21 , 54 , 61 } ; int N = arr . Length ; int K = 4 ; minimumRange ( arr , N , K ) ; } }

Index/key variables: left, right
Accumulator variables: i, left, right
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void splitArray ( int [ ] arr , int n , int K ) { Array . Sort ( arr ) ; int i = n - 1 ; int result = 0 ; while ( K -- != 0 ) { result += arr [ i - 1 ] ; i -= 2 ; } Console . Write ( result ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 3 , 1 , 5 , 1 , 3 } ; int N = arr . Length ; int K = 2 ; splitArray ( arr , N , K ) ; } }

Accumulator variables: K, i, result
Class/struct names: GFG
C# program:
using System ; class GFG { static void merge ( int [ ] indices , int [ ] a , int l , int mid , int r ) { int [ ] temp_ind = new int [ r - l + 1 ] ; int j = mid + 1 ; int i = 0 , temp_l = l , k ; while ( l <= mid && j <= r ) { if ( a [ indices [ l ] ] < a [ indices [ j ] ] ) temp_ind [ i ++ ] = indices [ l ++ ] ; else temp_ind [ i ++ ] = indices [ j ++ ] ; } while ( l <= mid ) temp_ind [ i ++ ] = indices [ l ++ ] ; while ( j <= r ) temp_ind [ i ++ ] = indices [ j ++ ] ; for ( k = 0 ; k < i ; k ++ ) indices [ temp_l ++ ] = temp_ind [ k ] ; } static void divide ( int [ ] indices , int [ ] a , int l , int r ) { if ( l >= r ) return ; int mid = l / 2 + r / 2 ; divide ( indices , a , l , mid ) ; divide ( indices , a , mid + 1 , r ) ; merge ( indices , a , l , mid , r ) ; } static void noOfSubsequences ( int [ ] arr , int N ) { int [ ] indices = new int [ N ] ; int i ; for ( i = 0 ; i < N ; i ++ ) indices [ i ] = i ; divide ( indices , arr , 0 , N - 1 ) ; int [ ] B = new int [ N ] ; int subseq = 1 ; for ( i = 0 ; i < N ; i ++ ) { B [ indices [ i ] ] = subseq ; subseq *= 2 ; } for ( i = 0 ; i < N ; i ++ ) Console . Write ( B [ i ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 1 } ; int N = arr . Length ; noOfSubsequences ( arr , N ) ; } }

Index/key variables: N, i, j, k, l
Accumulator variables: i, j, k, l, subseq, temp_l
Iterator variables: i, k
Class/struct names: GFG
C# program:
using System ; class GFG { static void merge ( int [ ] order , int [ ] freq , int i , int mid , int j ) { int [ ] tempOrder = new int [ j - i + 1 ] ; int temp = mid + 1 , index = - 1 ; while ( i <= mid && temp <= j ) { if ( freq [ order [ i ] ] <= freq [ order [ temp ] ] ) { tempOrder [ ++ index ] = order [ i ++ ] ; } else { tempOrder [ ++ index ] = order [ temp ++ ] ; } } while ( i <= mid ) { tempOrder [ ++ index ] = order [ i ++ ] ; } while ( temp <= j ) { tempOrder [ ++ index ] = order [ temp ++ ] ; } int ind = index ; for ( index = ind ; index >= 0 ; index -- ) { order [ j -- ] = tempOrder [ index ] ; } } static void divide ( int [ ] order , int [ ] freq , int i , int j ) { if ( i >= j ) return ; int mid = i / 2 + j / 2 ; divide ( order , freq , i , mid ) ; divide ( order , freq , mid + 1 , j ) ; merge ( order , freq , i , mid , j ) ; } static void orderProcesses ( int [ ] A , int N , int q ) { int i = 0 ; int [ ] freq = new int [ N ] ; for ( i = 0 ; i < N ; i ++ ) { freq [ i ] = ( A [ i ] / q ) ; if ( A [ i ] % q > 0 ) freq [ i ] += 1 ; } int [ ] order = new int [ 4 ] ; for ( i = 0 ; i < N ; i ++ ) { order [ i ] = i ; } divide ( order , freq , 0 , N - 1 ) ; for ( i = 0 ; i < N ; i ++ ) { Console . Write ( order [ i ] + " ▁ " ) ; } } public static void Main ( ) { int [ ] arr = { 3 , 7 , 4 } ; int Q = 3 ; int N = arr . Length ; orderProcesses ( arr , N , Q ) ; } }

Index/key variables: N, i, index, temp
Accumulator variables: i, index, j, temp
Iterator variables: i, index
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxCostToRemove ( int [ ] arr , int N , int K ) { int maxCost = 0 ; Array . Sort ( arr ) ; for ( int i = 0 ; i < N ; i += K ) { maxCost += arr [ i + 1 ] ; } return maxCost ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 3 , 4 , 1 , 5 , 1 , 5 , 3 } ; int N = arr . Length ; int K = 4 ; Console . Write ( maxCostToRemove ( arr , N , K ) ) ; } }

Accumulator variables: i, maxCost
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static String convert_to_words ( int n ) { char [ ] num = String . Join ( " " , n ) . ToCharArray ( ) ; int len = num . Length ; String ans = " " ; if ( len == 0 ) { ans += " Empty ▁ String " ; return ans ; } String [ ] single_digits = new String [ ] { " zero " , " one " , " two " , " three " , " four " , " five " , " six " , " seven " , " eight " , " nine " } ; String [ ] two_digits = new String [ ] { " " , " ten " , " eleven " , " twelve " , " thirteen " , " fourteen " , " fifteen " , " sixteen " , " seventeen " , " eighteen " , " nineteen " } ; String [ ] tens_multiple = new String [ ] { " " , " " , " twenty " , " thirty " , " forty " , " fifty " , " sixty " , " seventy " , " eighty " , " ninety " } ; String [ ] tens_power = new String [ ] { " hundred " , " thousand " } ; if ( len == 1 ) { ans += single_digits [ num [ 0 ] - '0' ] ; return ans ; } int x = 0 ; while ( x < num . Length ) { if ( len >= 3 ) { if ( num [ x ] - '0' != 0 ) { ans += single_digits [ num [ x ] - '0' ] ; ans += " ▁ " ; ans += tens_power [ len - 3 ] ; ans += " ▁ " ; } -- len ; } else { if ( num [ x ] - '0' == 1 ) { int sum = num [ x ] - '0' + num [ x ] - '0' ; ans += two_digits [ sum ] ; return ans ; } else if ( num [ x ] - '0' == 2 && num [ x + 1 ] - '0' == 0 ) { ans += " twenty " ; return ans ; } else { int i = ( num [ x ] - '0' ) ; if ( i > 0 ) { ans += tens_multiple [ i ] ; ans += " ▁ " ; } else ans += " " ; ++ x ; if ( num [ x ] - '0' != 0 ) ans += single_digits [ num [ x ] - '0' ] ; } } ++ x ; } return " " ; } static void lexNumbers ( int n ) { List < String > s = new List < String > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { s . Add ( convert_to_words ( i ) ) ; } s . Sort ( ) ; List < String > ans = new List < String > ( ) ; for ( int i = 0 ; i < n ; i ++ ) ans . Add ( s [ i ] ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) Console . Write ( ans [ i ] + " , ▁ " ) ; Console . Write ( ans [ n - 1 ] ) ; } public static void Main ( String [ ] args ) { int n = 5 ; lexNumbers ( n ) ; } }

Index/key variables: i, sum, x
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static void minimumCost ( int [ ] binary , int n , int a , int b ) { List < int > groupOfZeros = new List < int > ( ) ; int len = 0 , i = 0 ; bool increment_need = true ; while ( i < n ) { increment_need = true ; while ( i < n && binary [ i ] == 0 ) { len ++ ; i ++ ; increment_need = false ; } if ( increment_need == true ) { i ++ ; } if ( len != 0 ) { groupOfZeros . Add ( len ) ; } len = 0 ; } groupOfZeros . Sort ( ) ; i = 0 ; bool found_ones = false ; int NumOfOnes = 0 ; while ( i < n ) { found_ones = false ; while ( i < n && binary [ i ] == 1 ) { i ++ ; found_ones = true ; } if ( found_ones == false ) i ++ ; else NumOfOnes ++ ; } int ans = int . MaxValue ; for ( int i1 = 0 ; i1 < n ; i1 ++ ) { int curr = 0 , totalOnes = NumOfOnes ; if ( i1 == 0 ) { curr = totalOnes * a ; } else { int mark = i1 , num_of_changes = 0 ; foreach ( int x in groupOfZeros ) { if ( mark >= x ) { totalOnes -- ; mark -= x ; num_of_changes += x ; } else { break ; } } curr = ( num_of_changes * b ) + ( totalOnes * a ) ; } ans = Math . Min ( ans , curr ) ; } Console . WriteLine ( ans ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 1 , 1 , 0 , 1 , 1 } ; int N = 6 ; int X = 10 , Y = 4 ; minimumCost ( arr , N , X , Y ) ; } }

Index/key variables: i
Accumulator variables: NumOfOnes, i, i1, len, mark, num_of_changes, totalOnes
Iterator variables: i1, x
Boolean variables: found_ones, increment_need
Class/struct names: GFG
C# program:
using System ; class GFG { static int isSortedparitions ( int [ ] arr , int i , int j ) { for ( int k = i + 1 ; k <= j ; k ++ ) { if ( arr [ k ] < arr [ k - 1 ] ) { return 0 ; } } return 1 ; } static int partitionsArr ( int [ ] arr , int i , int j ) { if ( i >= j ) return 1 ; int flag = ( int ) isSortedparitions ( arr , i , j ) ; if ( flag != 0 ) { return ( j - i + 1 ) ; } int mid = ( i + j ) / 2 ; int X = partitionsArr ( arr , i , mid ) ; int Y = partitionsArr ( arr , mid + 1 , j ) ; return Math . Max ( X , Y ) ; } public static void Main ( ) { int [ ] arr = { 11 , 12 , 1 , 2 , 13 , 14 , 3 , 4 } ; int N = arr . Length ; Console . Write ( partitionsArr ( arr , 0 , N - 1 ) ) ; } }

Index/key variables: k
Accumulator variables: k
Iterator variables: k
Class/struct names: GFG
C# program:
using System ; class GFG { static bool checkIfPossibleMerge ( int [ ] A , int [ ] B , int N ) { int i = 0 ; int j = 0 ; int prev = - 1 ; bool flag = true ; while ( i < N && j < N ) { if ( A [ i ] < B [ j ] && prev != 0 ) { prev = 0 ; i ++ ; } else if ( B [ j ] < A [ i ] && prev != 1 ) { prev = 1 ; j ++ ; } else if ( A [ i ] == B [ j ] ) { if ( prev != 1 ) { prev = 1 ; j ++ ; } else { prev = 0 ; i ++ ; } } else { flag = false ; break ; } } return flag ; } public static void Main ( ) { int [ ] A = { 3 , 5 , 8 } ; int [ ] B = { 2 , 4 , 6 } ; int N = A . Length ; if ( checkIfPossibleMerge ( A , B , N ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }

Index/key variables: i, j
Accumulator variables: i, j
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; class GFG { static int minimum_possible_sum ( int [ ] arr , int n , int k ) { if ( n == 0 ) { return 0 ; } if ( n == 1 ) { return arr [ 0 ] ; } for ( int i = 0 ; i < k ; i ++ ) { int smallest_element = arr [ 0 ] ; int smallest_pos = 0 ; int largest_element = arr [ 0 ] ; int largest_pos = 0 ; for ( int j = 1 ; j < n ; j ++ ) { if ( arr [ j ] >= largest_element ) { largest_element = arr [ j ] ; largest_pos = j ; } if ( arr [ j ] < smallest_element ) { smallest_element = arr [ j ] ; smallest_pos = j ; } } int a = smallest_element * 2 ; int b = largest_element / 2 ; if ( a + b < smallest_element + largest_element ) { arr [ smallest_pos ] = a ; arr [ largest_pos ] = b ; } } int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ans += arr [ i ] ; } return ans ; } public static void Main ( ) { int [ ] arr = { 50 , 1 , 100 , 100 , 1 } ; int K = 2 ; int n = arr . Length ; Console . WriteLine ( minimum_possible_sum ( arr , n , K ) ) ; } }

Index/key variables: i, j, largest_pos, smallest_pos
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int maxSum ( int n , int [ ] a , int [ , ] l , int q ) { List < int > v = new List < int > ( ) ; int [ ] d = new int [ n ] ; for ( int i = 0 ; i < q ; i ++ ) { for ( int x = l [ i , 0 ] ; x <= l [ i , 1 ] ; x ++ ) { if ( d [ x ] == 0 ) { d [ x ] = 1 ; } } } HashSet < int > st = new HashSet < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( d [ i ] == 0 ) { v . Add ( a [ i ] ) ; st . Add ( i ) ; } } v . Sort ( ) ; v . Reverse ( ) ; int c = 0 ; foreach ( int it in st ) { a [ it ] = v ; c ++ ; } int pref_sum = 0 ; int temp_sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { temp_sum += a [ i ] ; pref_sum += temp_sum ; } return pref_sum ; } public static void Main ( String [ ] args ) { int [ ] arr = { - 8 , 4 , - 2 , - 6 , 4 , 7 , 1 } ; int N = arr . Length ; int [ , ] q = { { 0 , 0 } , { 4 , 5 } } ; int queries = q . GetLength ( 0 ) ; Console . Write ( maxSum ( N , arr , q , queries ) ) ; } }

Index/key variables: i, it, n, x
Accumulator variables: c, i, pref_sum, temp_sum, x
Iterator variables: i, it, x
Class/struct names: GFG
C# program:
using System ; class GFG { static void countPairs ( int [ ] A , int N ) { int count = 0 ; Array . Sort ( A ) ; int [ ] bits = new int [ 32 ] ; for ( int i = 0 ; i < N ; i ++ ) { if ( A [ i ] == 0 ) { continue ; } for ( int j = 0 ; j < 32 ; j ++ ) { if ( ( ( 1 << j ) & A [ i ] ) == 0 ) { count += bits [ j ] ; } } ++ bits [ ( int ) ( ( int ) ( Math . Log ( A [ i ] ) / Math . Log ( 2 ) ) ) ] ; } Console . WriteLine ( count ) ; } public static void Main ( ) { int [ ] arr = { 2 , 4 , 3 } ; int N = arr . Length ; countPairs ( arr , N ) ; } }

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 ; using System . Collections . Generic ; class GFG { static void mostvisitedsector ( int N , ArrayList A ) { int maxVisited = 0 ; Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < A . Count - 1 ; i ++ ) { int start = ( int ) A [ i ] % N ; int end = ( int ) A [ i + 1 ] % N ; while ( start != end ) { if ( start == 0 ) { if ( mp . ContainsKey ( N ) ) mp [ N ] = mp [ N ] + 1 ; else mp [ N ] = 1 ; if ( mp [ N ] > maxVisited ) { maxVisited = mp [ N ] ; } } else { if ( mp . ContainsKey ( start ) ) mp [ start ] = mp [ start ] + 1 ; else mp [ start ] = 1 ; if ( mp [ start ] > maxVisited ) { maxVisited = mp [ start ] ; } } start = ( start + 1 ) % N ; } } int last_element = ( int ) A [ A . Count - 1 ] ; if ( mp . ContainsKey ( last_element ) ) mp [ last_element ] = mp [ last_element ] + 1 ; else mp [ last_element ] = 1 ; if ( mp [ last_element ] > maxVisited ) { maxVisited = mp [ last_element ] ; } foreach ( var x in mp ) { if ( ( int ) x . Value == maxVisited ) { Console . Write ( x . Key + " ▁ " ) ; } } } public static void Main ( ) { int N = 4 ; ArrayList arr = new ArrayList ( ) { 1 , 2 , 1 , 2 } ; mostvisitedsector ( N , arr ) ; } }

Index/key variables: N, i, last_element, start
Accumulator variables: i
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxRectangle ( int [ , ] sequence , int size ) { int [ ] X_Cord = new int [ size ] ; int [ ] Y_Cord = new int [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { X_Cord [ i ] = sequence [ i , 0 ] ; Y_Cord [ i ] = sequence [ i , 1 ] ; } Array . Sort ( X_Cord ) ; Array . Sort ( Y_Cord ) ; int X_Max = 0 , Y_Max = 0 ; for ( int i = 0 ; i < size - 1 ; i ++ ) { X_Max = Math . Max ( X_Max , X_Cord [ i + 1 ] - X_Cord [ i ] ) ; Y_Max = Math . Max ( Y_Max , Y_Cord [ i + 1 ] - Y_Cord [ i ] ) ; } return X_Max * Y_Max ; } public static void Main ( String [ ] args ) { int [ , ] point = { { - 2 , 0 } , { 2 , 0 } , { 4 , 0 } , { 4 , 2 } } ; int n = point . GetLength ( 0 ) ; Console . Write ( maxRectangle ( point , n ) ) ; } }

Index/key variables: i, size
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static void checkArrangement ( int [ ] A1 , int [ ] A2 , int n , int k ) { Array . Sort ( A1 ) ; Array . Sort ( A2 ) ; Array . Reverse ( A2 ) ; int flag = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( A1 [ i ] + A2 [ i ] > k ) || ( A1 [ i ] + A2 [ i ] < k / 2 ) ) { flag = 1 ; break ; } } if ( flag == 1 ) Console . WriteLine ( " No " ) ; else Console . WriteLine ( " Yes " ) ; } public static void Main ( ) { int [ ] arr1 = { 1 , 3 , 4 , 5 } ; int [ ] arr2 = { 2 , 0 , 1 , 1 } ; int K = 6 ; int N = arr1 . Length ; checkArrangement ( arr1 , arr2 , N , K ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MaxRearrngeSum ( int [ ] A , int [ ] B , int N ) { Array . Sort ( A ) ; Array . Sort ( B ) ; Array . Reverse ( B ) ; int maxSum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { maxSum += Math . Abs ( A [ i ] - B [ i ] ) ; } return maxSum ; } public static void Main ( ) { int [ ] A = { 1 , 2 , 2 , 4 , 5 } ; int [ ] B = { 5 , 5 , 5 , 6 , 6 } ; int N = A . Length ; Console . WriteLine ( MaxRearrngeSum ( A , B , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, maxSum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int largestArea ( int [ ] arr1 , int n , int [ ] arr2 , int m ) { int end = 0 , start = 0 , i = 0 , j = 0 ; Array . Sort ( arr1 ) ; Array . Sort ( arr2 ) ; while ( i < n && j < m ) { if ( arr1 [ i ] == arr2 [ j ] ) { if ( start == 0 ) start = arr1 [ i ] ; else end = arr1 [ i ] ; i ++ ; j ++ ; } else if ( arr1 [ i ] > arr2 [ j ] ) j ++ ; else i ++ ; } if ( end == 0 start == 0 ) return 0 ; else return ( end - start ) ; } static void Main ( ) { int [ ] arr1 = { 1 , 2 , 4 } ; int N = arr1 . Length ; int [ ] arr2 = { 1 , 3 , 4 } ; int M = arr2 . Length ; Console . WriteLine ( largestArea ( arr1 , N , arr2 , M ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int count_pairs ( int [ ] arr , int [ ] brr , int N , int M , int K ) { int i = 0 ; int j = 0 ; int cntPairs = 0 ; Array . Sort ( arr ) ; Array . Sort ( brr ) ; while ( i < N && j < M ) { if ( brr [ j ] - arr [ i ] > K ) { cntPairs += ( M - j ) ; i ++ ; } else { j ++ ; } } return cntPairs ; } static void Main ( ) { int [ ] arr = { 5 , 9 , 1 , 8 } ; int [ ] brr = { 10 , 12 , 7 , 4 , 2 , 3 } ; int K = 3 ; int N = arr . Length ; int M = brr . Length ; Console . WriteLine ( count_pairs ( arr , brr , N , M , K ) ) ; } }

Index/key variables: i, j
Accumulator variables: cntPairs, i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void minHeapify ( int [ ] brr , int i , int M ) { int left = 2 * i + 1 ; int right = 2 * i + 2 ; int smallest = i ; if ( left < M && brr [ left ] < brr [ smallest ] ) { smallest = left ; } if ( right < M && brr [ right ] < brr [ smallest ] ) { smallest = right ; } if ( smallest != i ) { int temp = brr [ i ] ; brr [ i ] = brr [ smallest ] ; brr [ smallest ] = temp ; minHeapify ( brr , smallest , M ) ; } } static void merge ( int [ ] arr , int [ ] brr , int N , int M ) { for ( int i = 0 ; i < N ; ++ i ) { if ( arr [ i ] > brr [ 0 ] ) { int temp = arr [ i ] ; arr [ i ] = brr [ 0 ] ; brr [ 0 ] = temp ; minHeapify ( brr , 0 , M ) ; } } Array . Sort ( brr ) ; } static void printArray ( int [ ] arr , int N ) { for ( int i = 0 ; i < N ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 23 , 35 , 235 , 2335 } ; int [ ] brr = { 3 , 5 } ; int N = arr . Length ; int M = brr . Length ; merge ( arr , brr , N , M ) ; printArray ( arr , N ) ; printArray ( brr , M ) ; } }

Index/key variables: i, left, right, smallest
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void partition ( int [ ] arr , int N , int [ ] brr , int M , int Pivot ) { int l = N - 1 ; int r = 0 ; while ( l >= 0 && r < M ) { if ( arr [ l ] < Pivot ) l -- ; else if ( brr [ r ] > Pivot ) r ++ ; else { int t = arr [ l ] ; arr [ l ] = brr [ r ] ; brr [ r ] = t ; l -- ; r ++ ; } } } static void Merge ( int [ ] arr , int N , int [ ] brr , int M ) { int l = 0 ; int r = 0 ; int index = - 1 ; int Pivot = 0 ; while ( index < N && l < N && r < M ) { if ( arr [ l ] < brr [ r ] ) { Pivot = arr [ l ++ ] ; } else { Pivot = brr [ r ++ ] ; } index ++ ; } while ( index < N && l < N ) { Pivot = arr [ l ++ ] ; index ++ ; } while ( index < N && r < M ) { Pivot = brr [ r ++ ] ; index ++ ; } partition ( arr , N , brr , M , Pivot ) ; Array . Sort ( arr ) ; Array . Sort ( brr ) ; for ( int i = 0 ; i < N ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; for ( int i = 0 ; i < M ; i ++ ) Console . Write ( brr [ i ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 5 , 9 } ; int [ ] brr = { 2 , 4 , 7 , 10 } ; int N = arr . Length ; int M = brr . Length ; Merge ( arr , N , brr , M ) ; } }

Index/key variables: i, l, r
Accumulator variables: i, index, l, r
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int rankLessThanK ( int [ ] arr , int k , int n ) { int rank = 1 ; int position = 1 ; Array . Sort ( arr ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( i == n - 1 arr [ i ] != arr [ i + 1 ] ) { rank = position ; if ( rank > k ) return position - 1 ; } position ++ ; } return n ; } public static void Main ( ) { int [ ] arr = { 2 , 2 , 3 , 4 , 5 } ; int N = arr . Length ; int K = 4 ; Console . WriteLine ( rankLessThanK ( arr , K , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, position
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static void eraseSubdirectory ( ArrayList dir ) { ArrayList res = new ArrayList ( ) ; dir . Sort ( ) ; res . Add ( dir [ 0 ] ) ; Console . Write ( " { " + dir [ 0 ] + " , ▁ " ) ; for ( int i = 1 ; i < dir . Count ; i ++ ) { string curr = ( string ) dir [ i ] ; string prev = ( string ) res [ ( res . Count - 1 ) ] ; int l = prev . Length ; if ( curr . Length > l && curr [ l ] == ' / ' && prev . Equals ( curr . Substring ( 0 , l ) ) ) continue ; res . Add ( curr ) ; Console . Write ( curr + " , ▁ " ) ; } Console . Write ( " } STRNEWLINE " ) ; } public static void Main ( ) { ArrayList dir = new ArrayList ( ) { " / a " , " / a / j " , " / c / d / e " , " / c / d " , " / b " } ; eraseSubdirectory ( dir ) ; } }

Index/key variables: i, l
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void minCost ( int [ ] arr , int n ) { if ( n == 1 ) { Console . Write ( 0 + " STRNEWLINE " ) ; return ; } Array . Sort ( arr ) ; float raised = 1 / ( float ) ( n - 1 ) ; float temp = ( float ) Math . Pow ( arr [ n - 1 ] , raised ) ; int r = ( int ) ( temp ) + 1 ; int i , j , min_cost = int . MaxValue ; int common_ratio = 1 ; for ( j = 1 ; j <= r ; j ++ ) { int curr_cost = 0 , prod = 1 ; for ( i = 0 ; i < n ; i ++ ) { curr_cost += Math . Abs ( arr [ i ] - prod ) ; prod *= j ; if ( curr_cost >= min_cost ) break ; } if ( i == n ) { min_cost = Math . Min ( min_cost , curr_cost ) ; common_ratio = j ; } } Console . Write ( min_cost + " ▁ " ) ; Console . Write ( common_ratio + " ▁ " ) ; } public static void Main ( String [ ] args ) { int N = 6 ; int [ ] arr = { 1 , 11 , 4 , 27 , 15 , 33 } ; minCost ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: curr_cost, i, j, prod
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxN = 10 ; static void calculateFib ( int [ ] fib , int n ) { fib [ 0 ] = fib [ 1 ] = 1 ; for ( int x = 2 ; x < n ; x ++ ) { fib [ x ] = fib [ x - 1 ] + fib [ x - 2 ] ; } } static int find_mth_bit ( int n , int m , int [ ] fib ) { if ( n <= 1 ) { return n ; } int len_left = fib [ n - 2 ] ; int len_right = fib [ n - 1 ] ; if ( m <= len_left ) { return find_mth_bit ( n - 2 , len_left + 1 - m , fib ) ; } else { return find_mth_bit ( n - 1 , len_right + 1 - ( m - len_left ) , fib ) ; } } static void find_mth_bitUtil ( int n , int m ) { int [ ] fib = new int [ maxN ] ; calculateFib ( fib , maxN ) ; int ans = find_mth_bit ( n , m , fib ) ; Console . Write ( ans + " ▁ " ) ; } public static void Main ( ) { int n = 5 , m = 3 ; find_mth_bitUtil ( n , m ) ; } }

Index/key variables: maxN, x
Accumulator variables: x
Iterator variables: x
Class/struct names: GFG