dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static String sortString ( String str , int n ) { int i ; char [ ] arr = new char [ 26 ] ; String new_str = " " ; for ( i = 0 ; i < n ; i ++ ) ++ arr [ str [ i ] - ' a ' ] ; for ( i = 0 ; i < 26 ; i ++ ) while ( arr [ i ] -- > 0 ) { new_str += String . Join ( " " , ( char ) ( i + ' a ' ) ) ; } return new_str ; } public static void Main ( String [ ] args ) { String str = " geeksforgeeks " ; int n = str . Length ; Console . Write ( sortString ( str , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, new_str
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { class Node { public char data ; public Node next ; } ; static Node head ; static char maxChar ( Node head ) { Node p = head ; int [ ] hash = new int [ 256 ] ; while ( p != null ) { hash [ p . data ] ++ ; p = p . next ; } p = head ; int max = - 1 ; char res = ' \x0000' ; while ( p != null ) { if ( max < hash [ p . data ] ) { res = p . data ; max = hash [ p . data ] ; } p = p . next ; } return res ; } static void push ( Node head_ref , char new_data ) { Node new_node = new Node ( ) ; new_node . data = new_data ; new_node . next = head_ref ; head_ref = new_node ; head = head_ref ; } public static void Main ( String [ ] args ) { head = null ; char [ ] str = " skeegforskeeg " . ToCharArray ( ) ; for ( int i = 0 ; i < str . Length ; i ++ ) { push ( head , str [ i ] ) ; } Console . WriteLine ( maxChar ( head ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Node
C# program:
using System ; class GFG { static int N = 3 ; static int getGreatestSum ( int [ , ] a ) { int prev_max = 0 ; for ( int j = 0 ; j < N ; j ++ ) if ( prev_max < a [ N - 1 , j ] ) prev_max = a [ N - 1 , j ] ; int sum = prev_max ; for ( int i = N - 2 ; i >= 0 ; i -- ) { int curr_max = - 2147483648 ; for ( int j = 0 ; j < N ; j ++ ) if ( prev_max > a [ i , j ] && a [ i , j ] > curr_max ) curr_max = a [ i , j ] ; if ( curr_max == - 2147483648 ) return - 1 ; prev_max = curr_max ; sum += prev_max ; } return sum ; } public static void Main ( ) { int [ , ] a = { { 1 , 2 , 3 } , { 4 , 5 , 6 } , { 7 , 8 , 9 } } ; Console . WriteLine ( getGreatestSum ( a ) ) ; int [ , ] b = { { 4 , 5 , 6 } , { 4 , 5 , 6 } , { 4 , 5 , 6 } } ; Console . WriteLine ( getGreatestSum ( b ) ) ; } }

Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GfG { public static void occurrenceDays ( int n , string firstday ) { String [ ] days = new String [ ] { " Monday " , " Tuesday " , " Wednesday " , " Thursday " , " Friday " , " Saturday " , " Sunday " } ; int [ ] count = new int [ 7 ] ; for ( int i = 0 ; i < 7 ; i ++ ) count [ i ] = 4 ; int pos = 0 ; for ( int i = 0 ; i < 7 ; i ++ ) { if ( firstday == days [ i ] ) { pos = i ; break ; } } int inc = n - 28 ; for ( int i = pos ; i < pos + inc ; i ++ ) { if ( i > 6 ) count [ i % 7 ] = 5 ; else count [ i ] = 5 ; } for ( int i = 0 ; i < 7 ; i ++ ) { Console . WriteLine ( days [ i ] + " ▁ " + count [ i ] ) ; } } public static void Main ( ) { int n = 31 ; string firstday = " Tuesday " ; occurrenceDays ( n , firstday ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GfG
C# program:
using System ; class GFG { static void findElement ( int n , int k ) { int ans = n ; int left = 1 ; int right = ( int ) ( Math . Pow ( 2 , n ) - 1 ) ; while ( true ) { int mid = ( left + right ) / 2 ; if ( k == mid ) { Console . WriteLine ( ans ) ; break ; } ans -- ; if ( k < mid ) { right = mid - 1 ; } else { left = mid + 1 ; } } } public static void Main ( ) { int n = 4 , k = 8 ; findElement ( n , k ) ; } }

Accumulator variables: ans
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { class Node { public int data ; public Node next ; } ; static Node push ( Node head_ref , int new_data ) { Node new_node = new Node ( ) ; new_node . data = new_data ; new_node . next = head_ref ; head_ref = new_node ; return head_ref ; } static int firstCommon ( Node head1 , Node head2 ) { for ( ; head1 != null ; head1 = head1 . next ) for ( Node p = head2 ; p != null ; p = p . next ) if ( p . data == head1 . data ) return head1 . data ; return 0 ; } public static void Main ( String [ ] args ) { Node head1 = null ; head1 = push ( head1 , 20 ) ; head1 = push ( head1 , 5 ) ; head1 = push ( head1 , 15 ) ; head1 = push ( head1 , 10 ) ; Node head2 = null ; head2 = push ( head2 , 10 ) ; head2 = push ( head2 , 2 ) ; head2 = push ( head2 , 15 ) ; head2 = push ( head2 , 8 ) ; Console . WriteLine ( firstCommon ( head1 , head2 ) ) ; } }

Iterator variables: p
Class/struct names: GFG, Node
C# program:
using System ; public class GFG { static int countMaxSumPairs ( int [ ] a , int n ) { int first = int . MinValue , second = int . MinValue ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] > first ) { second = first ; first = a [ i ] ; } else if ( a [ i ] > second && a [ i ] != first ) second = a [ i ] ; } int cnt1 = 0 , cnt2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == first ) cnt1 ++ ; if ( a [ i ] == second ) cnt2 ++ ; } if ( cnt1 == 1 ) return cnt2 ; if ( cnt1 > 1 ) return cnt1 * ( cnt1 - 1 ) / 2 ; return 0 ; } static float findMaxSumProbability ( int [ ] a , int n ) { int total = n * ( n - 1 ) / 2 ; int max_sum_pairs = countMaxSumPairs ( a , n ) ; return ( float ) max_sum_pairs / ( float ) total ; } static public void Main ( ) { int [ ] a = { 1 , 2 , 2 , 3 } ; int n = a . Length ; ; Console . WriteLine ( findMaxSumProbability ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: cnt1, cnt2, i
Iterator variables: i
Class/struct names: GFG
C# program:
int [ ] sum = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) sum [ i ] = sum [ i - 1 ] + arr [ i - 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) dp [ 1 , i ] = sum [ i ] ; and using as : best = Math . Min ( best , Math . Max ( dp [ i - 1 ] [ p ] , sum [ j ] - sum [ p ] ) ) ;

Index/key variables: i, j, p
Accumulator variables: i
Iterator variables: i
C# program:
for ( int i = k - 1 ; i <= n ; i ++ ) best = Math . Min ( best , Math . Max ( partition ( arr , i , k - 1 ) , sum ( arr , i , n - 1 ) ) ) ;

Accumulator variables: i
Iterator variables: i
C# program:
using System ; class GFG { static int findS ( int s ) { int sum = 0 ; for ( int n = 1 ; sum < s ; n ++ ) { sum += n ; if ( sum == s ) return n ; } return - 1 ; } public static void Main ( ) { int s = 15 ; int n = findS ( s ) ; if ( n == - 1 ) Console . WriteLine ( " - 1" ) ; else Console . WriteLine ( n ) ; } }

Accumulator variables: n, sum
Iterator variables: n
Class/struct names: GFG
C# program:
using System ; class GFG { public static int isvalid ( int s ) { double k = ( - 1.0 + Math . Sqrt ( 1 + 8 * s ) ) / 2 ; if ( Math . Ceiling ( k ) == Math . Floor ( k ) ) return ( int ) k ; else return - 1 ; } public static void Main ( string [ ] args ) { int s = 15 ; Console . Write ( isvalid ( s ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int calcSafe ( int pos ) { int j = pos % 10 ; int i = pos / 10 ; int dis_11 = Math . Min ( Math . Abs ( 1 - i ) , Math . Abs ( 1 - j ) ) ; int dis_18 = Math . Min ( Math . Abs ( 1 - i ) , Math . Abs ( 8 - j ) ) ; int dis_81 = Math . Min ( Math . Abs ( 8 - i ) , Math . Abs ( 1 - j ) ) ; int dis_88 = Math . Min ( Math . Abs ( 8 - i ) , Math . Abs ( 8 - j ) ) ; int sum = dis_11 + dis_18 + dis_81 + dis_88 + 1 ; return ( 64 - sum ) ; } public static void Main ( ) { int pos = 34 ; Console . WriteLine ( " Safe ▁ Positions ▁ = ▁ " + calcSafe ( pos ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int count_crossline ; static void merge ( int [ ] arr , int l , int m , int r ) { int i , j , k ; int n1 = m - l + 1 ; int n2 = r - m ; int [ ] L = new int [ n1 ] ; int [ ] R = new int [ n2 ] ; for ( i = 0 ; i < n1 ; i ++ ) { L [ i ] = arr [ l + i ] ; } for ( j = 0 ; j < n2 ; j ++ ) { R [ j ] = arr [ m + 1 + j ] ; } while ( i < n1 && j < n2 ) { if ( L [ i ] <= R [ j ] ) { arr [ k ] = L [ i ] ; i ++ ; } else { arr [ k ] = R [ j ] ; count_crossline += ( n1 - i ) ; j ++ ; } k ++ ; } while ( i < n1 ) { arr [ k ] = L [ i ] ; i ++ ; k ++ ; } while ( j < n2 ) { arr [ k ] = R [ j ] ; j ++ ; k ++ ; } } static void mergeSort ( int [ ] arr , int l , int r ) { if ( l < r ) { int m = l + ( r - l ) / 2 ; mergeSort ( arr , l , m ) ; mergeSort ( arr , m + 1 , r ) ; merge ( arr , l , m , r ) ; } } static int countCrossLine ( int [ ] arr , int n ) { mergeSort ( arr , 0 , n - 1 ) ; return count_crossline ; } public static void Main ( String [ ] args ) { int [ ] arr = { 12 , 11 , 13 , 5 , 6 , 7 } ; int n = arr . Length ; Console . WriteLine ( countCrossLine ( arr , n ) ) ; } }

Index/key variables: i, j, k, n1, n2
Accumulator variables: count_crossline, i, j, k
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int getCount ( int [ ] arr , int n , int num1 , int num2 ) { int i = 0 ; for ( i = 0 ; i < n ; i ++ ) if ( arr [ i ] == num1 ) break ; if ( i >= n - 1 ) return 0 ; int j ; for ( j = n - 1 ; j >= i + 1 ; j -- ) if ( arr [ j ] == num2 ) break ; if ( j == i ) return 0 ; return ( j - i - 1 ) ; } public static void Main ( ) { int [ ] arr = { 3 , 5 , 7 , 6 , 4 , 9 , 12 , 4 , 8 } ; int n = arr . Length ; int num1 = 5 , num2 = 4 ; Console . WriteLine ( getCount ( arr , n , num1 , num2 ) ) ; } }

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 ROW = 3 ; static int COL = 5 ; static int minTotalDistance ( int [ , ] grid ) { if ( ROW == 0 COL == 0 ) return 0 ; List < int > vertical = new List < int > ( ) ; List < int > horizontal = new List < int > ( ) ; for ( int i = 0 ; i < ROW ; i ++ ) { for ( int j = 0 ; j < COL ; j ++ ) { if ( grid [ i , j ] == 1 ) { vertical . Add ( i ) ; horizontal . Add ( j ) ; } } } vertical . Sort ( ) ; horizontal . Sort ( ) ; int size = vertical . Count / 2 ; int x = vertical [ size ] ; int y = horizontal [ size ] ; int distance = 0 ; for ( int i = 0 ; i < ROW ; i ++ ) for ( int j = 0 ; j < COL ; j ++ ) if ( grid [ i , j ] == 1 ) distance += Math . Abs ( x - i ) + Math . Abs ( y - j ) ; return distance ; } public static void Main ( String [ ] args ) { int [ , ] grid = { { 1 , 0 , 1 , 0 , 1 } , { 0 , 1 , 0 , 0 , 0 } , { 0 , 1 , 1 , 0 , 0 } } ; Console . WriteLine ( minTotalDistance ( grid ) ) ; } }

Index/key variables: size
Accumulator variables: distance, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class Test { static int sumOfDigit ( int K ) { int sod = 0 ; while ( K != 0 ) { sod += K % 10 ; K /= 10 ; } return sod ; } static int totalNumbersWithSpecificDifference ( int N , int diff ) { int low = 1 , high = N ; while ( low <= high ) { int mid = ( low + high ) / 2 ; if ( mid - sumOfDigit ( mid ) < diff ) low = mid + 1 ; else high = mid - 1 ; } return ( N - high ) ; } public static void Main ( ) { int N = 13 ; int diff = 2 ; Console . Write ( totalNumbersWithSpecificDifference ( N , diff ) ) ; } }

Accumulator variables: K, sod
Class/struct names: Test
C# program:
using System ; using System . Collections . Generic ; class GFG { static int getRandom ( int x , int y ) { return ( int ) ( x + new Random ( 10 ) . Next ( 1 ) * 10 % ( y - x + 1 ) ) ; } static int randomizedBinarySearch ( int [ ] arr , int l , int r , int x ) { while ( l <= r ) { int m = getRandom ( l , r ) ; if ( arr [ m ] == x ) return m ; if ( arr [ m ] < x ) l = m + 1 ; else r = m - 1 ; } return - 1 ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 4 , 10 , 40 } ; int n = arr . Length ; int x = 10 ; int result = randomizedBinarySearch ( arr , 0 , n - 1 , x ) ; if ( result == - 1 ) Console . Write ( " Element ▁ is ▁ not ▁ present ▁ in ▁ array " ) ; else Console . Write ( " Element ▁ is ▁ present ▁ at ▁ index ▁ { 0 } " , result ) ; } }

Index/key variables: m
Class/struct names: GFG
C# program:
using System ; class GFG { static int countBuildings ( int [ ] arr , int n ) { int count = 1 ; int curr_max = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] > curr_max arr [ i ] == curr_max ) { count ++ ; curr_max = arr [ i ] ; } } return count ; } public static void Main ( ) { int [ ] arr = { 7 , 4 , 8 , 2 , 9 } ; Console . Write ( countBuildings ( arr , arr . Length ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GfG { static int findExtra ( int [ ] arr1 , int [ ] arr2 , int n ) { for ( int i = 0 ; i < n ; i ++ ) if ( arr1 [ i ] != arr2 [ i ] ) return i ; return n ; } public static void Main ( ) { int [ ] arr1 = { 2 , 4 , 6 , 8 , 10 , 12 , 13 } ; int [ ] arr2 = { 2 , 4 , 6 , 8 , 10 , 12 } ; int n = arr2 . Length ; Console . Write ( findExtra ( arr1 , arr2 , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GfG
C# program:
using System ; class GFG { static int findExtra ( int [ ] arr1 , int [ ] arr2 , int n ) { int index = n ; int left = 0 , right = n - 1 ; while ( left <= right ) { int mid = ( left + right ) / 2 ; if ( arr2 [ mid ] == arr1 [ mid ] ) left = mid + 1 ; else { index = mid ; right = mid - 1 ; } } return index ; } public static void Main ( ) { int [ ] arr1 = { 2 , 4 , 6 , 8 , 10 , 12 , 13 } ; int [ ] arr2 = { 2 , 4 , 6 , 8 , 10 , 12 } ; int n = arr2 . Length ; Console . Write ( findExtra ( arr1 , arr2 , n ) ) ; } }

Index/key variables: mid
Class/struct names: GFG
C# program:
using System ; class GFG { public static int computeCost ( int [ ] arr , int N , int X ) { int cost = 0 ; for ( int i = 0 ; i < N ; i ++ ) cost += Math . Abs ( arr [ i ] - X ) ; return cost ; } public static int minCostToMakeElementEqual ( int [ ] arr , int N ) { int low , high ; low = high = arr [ 0 ] ; for ( int i = 0 ; i < N ; i ++ ) { if ( low > arr [ i ] ) low = arr [ i ] ; if ( high < arr [ i ] ) high = arr [ i ] ; } while ( ( high - low ) > 2 ) { int mid1 = low + ( high - low ) / 3 ; int mid2 = high - ( high - low ) / 3 ; int cost1 = computeCost ( arr , N , mid1 ) ; int cost2 = computeCost ( arr , N , mid2 ) ; if ( cost1 < cost2 ) high = mid2 ; else low = mid1 ; } return computeCost ( arr , N , ( low + high ) / 2 ) ; } public static void Main ( ) { int [ ] arr = { 1 , 100 , 101 } ; int N = arr . Length ; Console . Write ( minCostToMakeElementEqual ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: cost, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void minJumps ( int [ ] w , int [ ] l , int n ) { if ( n == 1 ) { Console . Write ( 0 ) ; return ; } int ans = 0 ; Dictionary < int , int > pos = new Dictionary < int , int > ( ) ; Dictionary < int , int > jump = new Dictionary < int , int > ( ) ; Dictionary < int , bool > filled = new Dictionary < int , bool > ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( pos . ContainsKey ( w [ i ] ) ) pos [ w [ i ] ] = i ; else pos . Add ( w [ i ] , i ) ; if ( filled . ContainsKey ( w [ i ] ) ) filled [ i ] = true ; else filled . Add ( i , true ) ; if ( jump . ContainsKey ( w [ i ] ) ) jump [ w [ i ] ] = l [ i ] ; else jump . Add ( w [ i ] , l [ i ] ) ; a [ i ] = w [ i ] ; } Array . Sort ( a ) ; for ( int curr = 1 ; curr < n ; curr ++ ) { int currElementPos = pos [ a [ curr ] ] ; int prevElementPos = pos [ a [ curr - 1 ] ] ; if ( currElementPos > prevElementPos ) continue ; while ( currElementPos <= prevElementPos || filled . ContainsKey ( currElementPos ) && filled [ currElementPos ] ) { currElementPos += jump [ a [ curr ] ] ; ans ++ ; } if ( pos . ContainsKey ( a [ curr ] ) ) pos [ a [ curr ] ] = currElementPos ; else pos . Add ( a [ curr ] , currElementPos ) ; if ( filled . ContainsKey ( currElementPos ) ) filled [ currElementPos ] = true ; else filled . Add ( currElementPos , true ) ; } Console . Write ( ans ) ; } public static void Main ( ) { int [ ] W = { 2 , 1 , 4 , 3 } ; int [ ] L = { 4 , 1 , 2 , 4 } ; int N = W . Length ; minJumps ( W , L , N ) ; } }

Index/key variables: curr, currElementPos, i, n
Accumulator variables: ans, curr, currElementPos, i
Iterator variables: curr, i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void check ( int [ ] arr , int n ) { for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i - 1 ] >= ( i - 1 ) ) { int p = arr [ i - 1 ] - ( i - 1 ) ; arr [ i ] += p ; arr [ i - 1 ] -= p ; } } for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] <= arr [ i - 1 ] ) { Console . Write ( " No " ) ; return ; } } Console . Write ( " Yes " ) ; } public static void Main ( ) { int [ ] arr = { 1 , 5 , 2 , 7 , 6 } ; int N = arr . Length ; check ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void minimumSize ( int [ ] arr , int N , int K ) { Array . Sort ( arr ) ; Array . Reverse ( arr ) ; if ( count ( arr , 0 ) == N ) Console . WriteLine ( 0 ) ; else if ( K >= N ) Console . WriteLine ( 1 ) ; else Console . WriteLine ( arr [ K ] ) ; } static void reverse ( int [ ] a ) { int i , t ; int n = a . Length ; for ( i = 0 ; i < n / 2 ; i ++ ) { t = a [ i ] ; a [ i ] = a [ n - i - 1 ] ; a [ n - i - 1 ] = t ; } } static int count ( int [ ] a , int n ) { int freq = 0 ; for ( int i = 0 ; i < a . Length ; i ++ ) { if ( a [ i ] == n ) freq ++ ; } return freq ; } public static void Main ( string [ ] args ) { int [ ] arr = { 2 , 4 , 8 , 2 } ; int K = 2 ; int N = arr . Length ; minimumSize ( arr , N , K ) ; } }

Index/key variables: K, i
Accumulator variables: freq, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System . IO ; using System ; class GFG { static void isPossibleToSort ( int [ ] arr , int N ) { int idx = - 1 ; for ( int i = 1 ; i < N ; i ++ ) { if ( arr [ i ] == 1 && arr [ i - 1 ] == 1 ) { idx = i ; break ; } } if ( idx == - 1 ) { Console . WriteLine ( " YES " ) ; return ; } for ( int i = idx + 1 ; i < N ; i ++ ) { if ( arr [ i ] == 0 && arr [ i - 1 ] == 0 ) { Console . WriteLine ( " NO " ) ; return ; } } Console . WriteLine ( " YES " ) ; } static void Main ( ) { int [ ] arr = { 1 , 0 , 1 , 0 , 1 , 1 , 0 } ; int N = arr . Length ; isPossibleToSort ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int maxConsecutiveRope ( int [ ] ropes , int N ) { int curSize = 0 ; Array . Sort ( ropes ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( ropes [ i ] <= curSize + 1 ) { curSize = curSize + ropes [ i ] ; } else break ; } return curSize ; } public static void Main ( ) { int N = 5 ; int [ ] ropes = { 1 , 2 , 7 , 1 , 1 } ; Console . WriteLine ( maxConsecutiveRope ( ropes , N ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int i , start , end ; static bool adjust ( string S ) { int N = S . Length ; start = i - 1 ; while ( i < N && S [ i ] < S [ i - 1 ] ) { i ++ ; } end = i - 1 ; if ( start <= 0 && i >= N ) return true ; if ( start >= 1 && i <= N ) { return ( S [ end ] >= S [ start - 1 ] && S [ start ] <= S [ i ] ) ; } if ( start >= 1 ) { return S [ end ] >= S [ start - 1 ] ; } if ( i < N ) { return S [ start ] <= S [ i ] ; } return false ; } static void isPossible ( string S , int N ) { start = - 1 ; end = - 1 ; bool flag = true ; for ( i = 1 ; i < N ; i ++ ) { if ( S [ i ] < S [ i - 1 ] ) { if ( flag ) { if ( adjust ( S ) == false ) { Console . WriteLine ( - 1 ) ; return ; } flag = false ; } else { Console . WriteLine ( - 1 ) ; return ; } } } if ( start == - 1 ) { start = end = 1 ; } Console . WriteLine ( start + " ▁ " + end ) ; } static void Main ( ) { string S = " abcyxuz " ; int N = S . Length ; isPossible ( S , N ) ; } }

Index/key variables: end, i, start
Accumulator variables: i
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; class GFG { static int maximumSum ( int [ ] arr , int [ ] S , int N , int K ) { int ans = 0 ; Array . Sort ( arr ) ; for ( int i = 0 ; i < N / 2 ; i ++ ) { int temp = arr [ i ] ; arr [ i ] = arr [ N - 1 - i ] ; arr [ N - 1 - i ] = temp ; } for ( int i = 0 ; i < K ; i ++ ) ans += arr [ i ] ; Array . Sort ( S ) ; for ( int i = 0 ; i < K ; i ++ ) { if ( S [ i ] == 1 ) ans += arr [ i ] ; S [ i ] -- ; } int counter = K - 1 ; for ( int i = 0 ; i < K ; i ++ ) { counter = counter + S [ i ] ; if ( S [ i ] != 0 ) ans += arr [ counter ] ; } return ans ; } public static void Main ( string [ ] args ) { int [ ] arr = { 1 , 13 , 7 , 17 } ; int [ ] S = { 1 , 3 } ; int N = arr . Length ; int K = S . Length ; Console . WriteLine ( maximumSum ( arr , S , N , K ) ) ; } }

Index/key variables: counter, i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isSortedArray ( int [ ] arr , int n ) { int l = 0 , r = ( n - 1 ) ; while ( ( l + 1 ) < r ) { if ( arr [ l ] >= Math . Max ( arr [ l + 1 ] , arr [ r - 1 ] ) && arr [ r ] >= Math . Max ( arr [ r - 1 ] , arr [ l + 1 ] ) ) { l ++ ; r -- ; } else { return false ; } } return true ; } public static void Main ( string [ ] args ) { int [ ] arr = { 4 , 3 , 1 , 2 , 5 } ; int N = arr . Length ; if ( isSortedArray ( arr , N ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Index/key variables: l, r
Accumulator variables: l, r
Class/struct names: GFG
C# program:
using System ; class GFG { static void maxLenSubset ( int [ ] a , int n ) { Array . Sort ( a ) ; int index = 0 , maxlen = - 1 ; int i = 0 ; while ( i < n ) { int j = i ; int len = 1 ; while ( j < n - 1 ) { if ( 2 * a [ j ] >= a [ j + 1 ] ) { len ++ ; } else break ; j ++ ; } if ( maxlen < len ) { maxlen = len ; index = i ; } j ++ ; i = j ; } i = index ; while ( maxlen > 0 ) { Console . Write ( a [ i ] + " ▁ " ) ; maxlen -- ; i ++ ; } } public static void Main ( string [ ] args ) { int [ ] a = { 3 , 1 , 5 , 11 } ; int n = a . Length ; maxLenSubset ( a , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, len, maxlen
Class/struct names: GFG
C# program:
using System ; class GFG { static void canReduceArray ( int [ ] arr , int N , int K ) { Array . Sort ( arr ) ; int [ ] b = new int [ N ] ; int j = N ; for ( int i = 0 ; i < N ; i ++ ) { b [ j - 1 ] = arr [ i ] ; j = j - 1 ; } for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( arr [ i ] - arr [ i + 1 ] > K ) { Console . WriteLine ( " No " ) ; return ; } } Console . WriteLine ( " Yes " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 1 , 1 , 3 } ; int N = arr . Length ; int K = 1 ; canReduceArray ( arr , N , K ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void mergeStrings ( string s1 , string s2 ) { int len1 = s1 . Length ; int len2 = s2 . Length ; int pntr1 = 0 ; int pntr2 = 0 ; string ans = " " ; while ( pntr1 < len1 && pntr2 < len2 ) { if ( s1 [ pntr1 ] < s2 [ pntr2 ] ) { ans += s1 [ pntr1 ] ; pntr1 ++ ; } else { ans += s2 [ pntr2 ] ; pntr2 ++ ; } } if ( pntr1 < len1 ) { ans += s1 . Substring ( pntr1 , len1 - pntr1 ) ; } if ( pntr2 < len2 ) { ans += s2 . Substring ( pntr2 , len2 - pntr2 ) ; } Console . WriteLine ( ans ) ; } public static void Main ( ) { string S1 = " abdcdtx " ; string S2 = " achilp " ; mergeStrings ( S1 , S2 ) ; } }

Index/key variables: pntr1, pntr2
Accumulator variables: ans, pntr1, pntr2
Class/struct names: GFG