dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int minAdjSwaps ( int [ , ] mat ) { int N = mat . GetLength ( 0 ) ; int [ ] cntZero = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = N - 1 ; j >= 0 && mat [ i , j ] == 0 ; j -- ) { cntZero [ i ] ++ ; } } int cntSwaps = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( cntZero [ i ] < ( N - i - 1 ) ) { int First = i ; while ( First < N && cntZero [ First ] < ( N - i - 1 ) ) { First ++ ; } if ( First == N ) { return - 1 ; } while ( First > i ) { cntZero = swap ( cntZero , First , First - 1 ) ; First -- ; cntSwaps ++ ; } } } return cntSwaps ; } static int [ ] swap ( int [ ] arr , int i , int j ) { int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; return arr ; } public static void Main ( String [ ] args ) { int [ , ] mat = { { 0 , 0 , 2 } , { 3 , 1 , 0 } , { 4 , 0 , 0 } } ; Console . Write ( minAdjSwaps ( mat ) ) ; } }

Index/key variables: First, N, i, j
Accumulator variables: First, cntSwaps, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void maxArea ( int [ ] point_x , int [ ] point_y , int n , int length , int width ) { Array . Sort ( point_x ) ; Array . Sort ( point_y ) ; int dx = point_x [ 0 ] ; int dy = point_y [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { dx = Math . Max ( dx , point_x [ i ] - point_x [ i - 1 ] ) ; dy = Math . Max ( dy , point_y [ i ] - point_y [ i - 1 ] ) ; } dx = Math . Max ( dx , ( length + 1 ) - point_x [ n - 1 ] ) ; dy = Math . Max ( dy , ( width + 1 ) - point_y [ n - 1 ] ) ; Console . WriteLine ( ( dx - 1 ) * ( dy - 1 ) ) ; } static public void Main ( ) { int length = 15 , width = 8 ; int n = 3 ; int [ ] point_x = { 3 , 11 , 8 } ; int [ ] point_y = { 8 , 2 , 6 } ; maxArea ( point_x , point_y , n , length , width ) ; } }

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 make_cuts ( int [ ] arr , int n , int K ) { int ans = 0 ; List < int > poss = new List < int > ( ) ; int ce = 0 ; int co = 0 ; for ( int x = 0 ; x < n - 1 ; x ++ ) { if ( arr [ x ] % 2 == 0 ) ce ++ ; else co ++ ; if ( ce == co && co > 0 && ce > 0 ) { poss . Add ( Math . Abs ( arr [ x ] - arr [ x + 1 ] ) ) ; } } poss . Sort ( ) ; foreach ( int x in poss ) { if ( K >= x ) { ans ++ ; K -= x ; } else break ; } return ans ; } public static void Main ( String [ ] args ) { int N = 6 ; int K = 4 ; int [ ] arr = { 1 , 2 , 5 , 10 , 15 , 20 } ; Console . Write ( make_cuts ( arr , N , K ) ) ; } }

Index/key variables: x
Accumulator variables: K, ans, ce, co, x
Iterator variables: x
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void Arrange ( int [ ] arr , int n ) { int cost = 0 ; Dictionary < int , int > index = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { index . Add ( arr [ i ] , i ) ; } Array . Sort ( arr ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == 0 ) { if ( arr [ i ] > arr [ i + 1 ] + arr [ n - 1 ] ) { Console . Write ( " - 1" ) ; return ; } else { cost += Math . Abs ( index [ arr [ i ] ] - i ) ; } } else if ( i == n - 1 ) { if ( arr [ i ] > arr [ i - 1 ] + arr [ 0 ] ) { Console . Write ( " - 1" ) ; return ; } else { cost += Math . Abs ( index [ arr [ i ] ] - i ) ; } } else { if ( arr [ i ] > arr [ i - 1 ] + arr [ i + 1 ] ) { Console . Write ( " - 1" ) ; return ; } else { cost += Math . Abs ( index [ arr [ i ] ] - i ) ; } } } Console . Write ( cost ) ; return ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 4 , 5 , 1 , 3 } ; int N = arr . Length ; Arrange ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: cost, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int XorSum ( int [ ] A , int [ ] B , int N ) { int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { ans = ans ^ ( A [ i ] + B [ j ] ) ; } } return ans ; } public static void Main ( String [ ] args ) { int [ ] A = { 4 , 6 , 0 , 0 , 3 , 3 } ; int [ ] B = { 0 , 5 , 6 , 5 , 0 , 3 } ; int N = A . Length ; Console . WriteLine ( XorSum ( A , B , N ) ) ; } }

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 maxDistinctChar ( char [ ] s , int n , int k ) { Dictionary < int , int > freq = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( freq . ContainsKey ( ( int ) s [ i ] ) ) { freq [ ( int ) s [ i ] ] = freq [ ( int ) s [ i ] ] + 1 ; } else { freq . Add ( ( int ) s [ i ] , 1 ) ; } } List < int > v = new List < int > ( ) ; foreach ( KeyValuePair < int , int > it in freq ) { v . Add ( it . Value ) ; } v . Sort ( ) ; for ( int i = 0 ; i < v . Count ; i ++ ) { int mn = Math . Min ( v [ i ] - 1 , k ) ; v [ i ] = v [ i ] - mn ; k -= mn ; } if ( k > 0 ) { for ( int i = 0 ; i < v . Count ; i ++ ) { int mn = Math . Min ( v [ i ] , k ) ; v [ i ] = v [ i ] - mn ; k -= mn ; } } int res = 0 ; for ( int i = 0 ; i < v . Count ; i ++ ) if ( v [ i ] == 1 ) res ++ ; return res ; } public static void Main ( String [ ] args ) { String S = " geeksforgeeks " ; int N = S . Length ; int K = 1 ; Console . Write ( maxDistinctChar ( S . ToCharArray ( ) , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: i, k, res
Iterator variables: i, it
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static List < int > primes = new List < int > ( ) ; static void SieveOfEratosthenes ( ) { bool [ ] prime = new bool [ 10005 ] ; for ( int i = 0 ; i < 10005 ; i ++ ) prime [ i ] = true ; for ( int p = 2 ; p * p <= 1000 ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= 1000 ; i += p ) prime [ i ] = false ; } } for ( int p = 2 ; p <= 1000 ; p ++ ) if ( prime [ p ] ) primes . Add ( p ) ; } static void generate ( int n , int k ) { List < int > prod = new List < int > ( ) ; SieveOfEratosthenes ( ) ; int l = primes . Count ; for ( int i = 0 ; i < l ; i ++ ) { for ( int j = i + 1 ; j < l ; j ++ ) { if ( primes [ i ] * primes [ j ] > 0 ) prod . Add ( primes [ i ] * primes [ j ] ) ; } } prod . Sort ( ) ; int sum = 0 ; for ( int i = 0 ; i < k - 1 ; i ++ ) sum += prod [ i ] ; if ( sum > n ) Console . Write ( " - 1" ) ; else { for ( int i = 0 ; i < k - 1 ; i ++ ) { Console . Write ( prod [ i ] + " , ▁ " ) ; } Console . Write ( n - sum + " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { int n = 52 , k = 5 ; generate ( n , k ) ; } }

Index/key variables: i, j, p
Accumulator variables: i, j, p, sum
Iterator variables: i, j, p
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMaxValue ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int ans = arr [ n - 1 ] ; int maxPossible = arr [ n - 1 ] ; for ( int i = n - 2 ; i >= 0 ; -- i ) { if ( maxPossible > 0 ) { if ( arr [ i ] >= maxPossible ) { ans += ( maxPossible - 1 ) ; maxPossible = maxPossible - 1 ; } else { maxPossible = arr [ i ] ; ans += maxPossible ; } } } return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , 4 , 1 , 5 } ; int n = arr . Length ; Console . Write ( findMaxValue ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: ans
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int maximizeFinalElement ( int [ ] arr , int n ) { Array . Sort ( arr ) ; if ( arr [ 0 ] != 1 ) arr [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] - arr [ i - 1 ] > 1 ) { arr [ i ] = arr [ i - 1 ] + 1 ; } } return arr [ n - 1 ] ; } public static void Main ( String [ ] args ) { int n = 4 ; int [ ] arr = { 3 , 1 , 3 , 4 } ; int max = maximizeFinalElement ( arr , n ) ; Console . WriteLine ( max ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findLeastDist ( int [ ] A , int N ) { Array . Sort ( A ) ; if ( N % 2 == 0 ) { return A [ ( N - 1 ) / 2 ] ; } else { return A [ N / 2 ] ; } } public static void Main ( string [ ] args ) { int [ ] A = { 4 , 1 , 5 , 10 , 2 } ; int N = A . Length ; Console . Write ( " ( " + findLeastDist ( A , N ) + " , ▁ " + 0 + " ) " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSubMatSum ( int [ , ] mat ) { int n = mat . GetLength ( 0 ) ; int m = mat . GetLength ( 1 ) ; int i , j ; int [ , ] dp = new int [ n , m ] ; dp [ n - 1 , m - 1 ] = mat [ n - 1 , m - 1 ] ; int res = dp [ n - 1 , m - 1 ] ; for ( i = m - 2 ; i >= 0 ; i -- ) { dp [ n - 1 , i ] = mat [ n - 1 , i ] + dp [ n - 1 , i + 1 ] ; res = Math . Max ( res , dp [ n - 1 , i ] ) ; } for ( i = n - 2 ; i >= 0 ; i -- ) { dp [ i , m - 1 ] = mat [ i , m - 1 ] + dp [ i + 1 , m - 1 ] ; res = Math . Max ( res , dp [ i , m - 1 ] ) ; } for ( i = n - 2 ; i >= 0 ; i -- ) { for ( j = m - 2 ; j >= 0 ; j -- ) { dp [ i , j ] = mat [ i , j ] + dp [ i , j + 1 ] + dp [ i + 1 , j ] - dp [ i + 1 , j + 1 ] ; res = Math . Max ( res , dp [ i , j ] ) ; } } return res ; } public static void Main ( String [ ] args ) { int [ , ] mat = { { - 6 , - 4 , - 1 } , { - 3 , 2 , 4 } , { 2 , 5 , 8 } } ; Console . Write ( maxSubMatSum ( mat ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Text ; class GFG { static String formAnInequality ( int [ ] integers , char [ ] inequalities ) { Array . Sort ( integers ) ; int lowerIndex = 0 ; int higherIndex = integers . Length - 1 ; StringBuilder sb = new StringBuilder ( ) ; foreach ( char ch in inequalities ) { if ( ch == ' < ' ) { sb . Append ( " ▁ " + integers [ lowerIndex ++ ] + " ▁ " + ch ) ; } else { sb . Append ( " ▁ " + integers [ higherIndex -- ] + " ▁ " + ch ) ; } } sb . Append ( " ▁ " + integers [ lowerIndex ] ) ; return sb . ToString ( ) ; } public static void Main ( String [ ] args ) { int [ ] integers = { 2 , 5 , 1 , 0 } ; char [ ] inequalities = { ' < ' , ' > ' , ' < ' } ; String output = formAnInequality ( integers , inequalities ) ; Console . WriteLine ( output ) ; } }

Index/key variables: lowerIndex
Accumulator variables: higherIndex, lowerIndex
Iterator variables: ch
Class/struct names: GFG
C# program:
using System ; class GFG { static bool canMadeEqual ( int [ ] A , int [ ] B , int n ) { Array . Sort ( A ) ; Array . Sort ( B ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( A [ i ] != B [ i ] ) { return false ; } } return true ; } public static void Main ( ) { int [ ] A = { 1 , 2 , 3 } ; int [ ] B = { 1 , 3 , 2 } ; int n = A . Length ; if ( canMadeEqual ( A , B , n ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxMinDifference ( int [ ] arr , int n , int k ) { if ( k >= n - 1 ) return 0 ; Array . Sort ( arr ) ; int ans = arr [ n - 1 ] - arr [ 0 ] ; for ( int i = k , j = n - 1 ; i >= 0 ; -- i , -- j ) { ans = Math . Min ( arr [ j ] - arr [ i ] , ans ) ; } return ans ; } public static void Main ( string [ ] args ) { int [ ] arr = new int [ ] { 1 , 4 , 6 , 11 , 15 } ; int N = arr . Length ; int K = 3 ; Console . Write ( maxMinDifference ( arr , N , K ) ) ; } }

Index/key variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void sortarray ( int [ ] arr , int N ) { if ( N == 3 ) Console . WriteLine ( " NO " ) ; else if ( N % 4 == 0 N % 4 == 1 ) { Console . WriteLine ( " YES " ) ; Console . WriteLine ( N / 2 ) ; int k = 1 ; for ( int l = 0 ; l < ( N / 4 ) ; l ++ ) { Console . WriteLine ( k + " ▁ " + ( k + 1 ) + " ▁ " + N ) ; Console . WriteLine ( k + 1 + " ▁ " + N + " ▁ " + ( N - 1 ) ) ; k = k + 2 ; N = N - 2 ; } } else Console . WriteLine ( " NO " ) ; } public static void Main ( ) { int N = 5 ; int [ ] arr = { 5 , 4 , 3 , 2 , 1 } ; sortarray ( arr , N ) ; } }

Accumulator variables: l
Iterator variables: l
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = ( int ) ( 1e5 + 5 ) ; class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void find_missing ( pair [ ] interval ) { int [ ] vis = new int [ MAX ] ; for ( int i = 0 ; i < interval . Length ; ++ i ) { int start = interval [ i ] . first ; int end = interval [ i ] . second ; vis [ start ] ++ ; vis [ end + 1 ] -- ; } for ( int i = 1 ; i < MAX ; i ++ ) { vis [ i ] += vis [ i - 1 ] ; if ( vis [ i ] == 0 ) { Console . Write ( i + " STRNEWLINE " ) ; return ; } } } public static void Main ( String [ ] args ) { pair [ ] interval = { new pair ( 0 , 14 ) , new pair ( 86 , 108 ) , new pair ( 22 , 30 ) , new pair ( 5 , 17 ) } ; find_missing ( interval ) ; } }

Index/key variables: MAX, i, start
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, pair
C# program:
using System ; using System . Collections . Generic ; class GFG { class Pair : IComparable < Pair > { public int start , end ; public Pair ( int s , int e ) { start = s ; end = e ; } public int CompareTo ( Pair p ) { return this . start - p . start ; } } static void findMissing ( List < Pair > interval ) { interval . Sort ( ) ; int mx = 0 ; for ( int i = 0 ; i < interval . Count ; ++ i ) { if ( interval [ i ] . start > mx ) { Console . WriteLine ( mx ) ; return ; } else mx = Math . Max ( mx , interval [ i ] . end + 1 ) ; } Console . WriteLine ( mx ) ; } public static void Main ( String [ ] args ) { List < Pair > interval = new List < Pair > ( ) ; interval . Add ( new Pair ( 0 , 14 ) ) ; interval . Add ( new Pair ( 86 , 108 ) ) ; interval . Add ( new Pair ( 22 , 30 ) ) ; interval . Add ( new Pair ( 5 , 17 ) ) ; findMissing ( interval ) ; } }

Index/key variables: i
Iterator variables: i
Class/struct names: GFG, Pair
C# program:
using System ; class GFG { static int build_num ( int [ ] bit ) { int ans = 0 ; for ( int i = 0 ; i < 32 ; i ++ ) if ( bit [ i ] == 1 ) ans += ( 1 << i ) ; ans += 32 ; return ans ; } static int maximumOR ( int [ ] arr , int n , int k ) { int [ ] bit = new int [ 32 ] ; for ( int i = 31 ; i >= 0 ; i -- ) { if ( bit [ i ] == 0 && k > 0 ) { int temp = build_num ( bit ) ; int temp1 = temp ; int val = - 1 ; for ( int j = 0 ; j < n ; j ++ ) { if ( temp1 < ( temp arr [ j ] ) ) { temp1 = temp | arr [ j ] ; val = arr [ j ] ; } } if ( val != - 1 ) { k -- ; for ( int j = 0 ; j < 32 ; j ++ ) { bit [ j ] ++ ; } } } } return build_num ( bit ) ; } public static void Main ( ) { int [ ] arr = { 5 , 9 , 7 , 19 } ; int k = 3 ; int n = arr . Length ; Console . Write ( maximumOR ( arr , n , k ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j, k
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void smallest_String ( char [ ] s , int m ) { int n = s . Length ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int distance = s [ i ] - ' a ' ; if ( distance == 0 ) a [ i ] = 0 ; else a [ i ] = 26 - distance ; } for ( int i = 0 ; i < n ; i ++ ) { if ( m >= a [ i ] ) { s [ i ] = ' a ' ; m = m - a [ i ] ; } } m = m % 26 ; s [ n - 1 ] = ( char ) ( s [ n - 1 ] + m ) ; Console . Write ( String . Join ( " " , s ) ) ; } public static void Main ( String [ ] args ) { String str = " aazzx " ; int m = 6 ; smallest_String ( str . ToCharArray ( ) , m ) ; } }

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 find_maximum_jobs ( int N , List < Tuple < int , int > > ranges ) { List < int > queue = new List < int > ( ) ; ranges . Sort ( ) ; int min_day = ranges [ 0 ] . Item1 ; int max_day = 0 ; for ( int i = 0 ; i < N ; i ++ ) max_day = Math . Max ( max_day , ranges [ i ] . Item2 ) ; int index = 0 , count_jobs = 0 ; for ( int i = min_day ; i <= max_day ; i ++ ) { while ( index < ranges . Count && ranges [ index ] . Item1 <= i ) { queue . Add ( ranges [ index ] . Item2 ) ; index ++ ; } queue . Sort ( ) ; while ( queue . Count > 0 && queue [ 0 ] < i ) queue . RemoveAt ( 0 ) ; if ( queue . Count == 0 ) continue ; count_jobs ++ ; queue . RemoveAt ( 0 ) ; } return count_jobs ; } static void Main ( ) { int N = 5 ; List < Tuple < int , int > > ranges = new List < Tuple < int , int > > ( ) ; ranges . Add ( new Tuple < int , int > ( 1 , 5 ) ) ; ranges . Add ( new Tuple < int , int > ( 1 , 5 ) ) ; ranges . Add ( new Tuple < int , int > ( 1 , 5 ) ) ; ranges . Add ( new Tuple < int , int > ( 2 , 3 ) ) ; ranges . Add ( new Tuple < int , int > ( 2 , 3 ) ) ; Console . Write ( find_maximum_jobs ( N , ranges ) ) ; } }

Index/key variables: i, index
Accumulator variables: count_jobs, i, index
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void minBox ( int [ ] arr , int n ) { int box = n ; Array . Sort ( arr ) ; int curr_box = 0 , next_box = 1 ; while ( curr_box < n && next_box < n ) { if ( arr [ curr_box ] < arr [ next_box ] ) { box -- ; curr_box ++ ; next_box ++ ; } else if ( arr [ curr_box ] == arr [ next_box ] ) next_box ++ ; } Console . WriteLine ( box ) ; } public static void Main ( String [ ] args ) { int [ ] size = { 1 , 2 , 3 } ; int n = size . Length ; minBox ( size , n ) ; } }

Index/key variables: curr_box, next_box
Accumulator variables: box, curr_box, next_box
Class/struct names: GFG
C# program:
using System ; class GFG { static node head1 = null ; static node head2 = null ; class node { public int data ; public node next ; } ; static void setData ( node head ) { node tmp ; tmp = head ; while ( tmp != null ) { Console . Write ( tmp . data + " ▁ - > ▁ " ) ; tmp = tmp . next ; } } static node getData ( node head , int num ) { node temp = new node ( ) ; node tail = head ; temp . data = num ; temp . next = null ; if ( head == null ) { head = temp ; tail = temp ; } else { while ( tail != null ) { if ( tail . next == null ) { tail . next = temp ; tail = tail . next ; } tail = tail . next ; } } return head ; } static node mergelists ( ) { node tail = head1 ; while ( tail != null ) { if ( tail . next == null && head2 != null ) { tail . next = head2 ; break ; } tail = tail . next ; } return head1 ; } static void sortlist ( ) { node curr = head1 ; node temp = head1 ; while ( curr . next != null ) { temp = curr . next ; while ( temp != null ) { if ( temp . data < curr . data ) { int t = temp . data ; temp . data = curr . data ; curr . data = t ; } temp = temp . next ; } curr = curr . next ; } } public static void Main ( String [ ] args ) { head1 = getData ( head1 , 4 ) ; head1 = getData ( head1 , 7 ) ; head1 = getData ( head1 , 5 ) ; head2 = getData ( head2 , 2 ) ; head2 = getData ( head2 , 1 ) ; head2 = getData ( head2 , 8 ) ; head2 = getData ( head2 , 1 ) ; head1 = mergelists ( ) ; sortlist ( ) ; setData ( head1 ) ; } }

Class/struct names: GFG, node
C# program:
using System ; class GFG { static double findMedian ( int [ ] a , int n ) { if ( n % 2 != 0 ) return ( double ) a [ n / 2 ] ; return ( double ) ( a [ ( n - 1 ) / 2 ] + a [ n / 2 ] ) / 2.0 ; } static void kStrongest ( int [ ] arr , int n , int k ) { Array . Sort ( arr ) ; int i = 0 ; double median = findMedian ( arr , n ) ; int [ ] diff = new int [ n ] ; for ( i = 0 ; i < n ; i ++ ) { diff [ i ] = ( int ) Math . Abs ( median - arr [ i ] ) ; } int j = n - 1 ; i = 0 ; while ( k > 0 ) { if ( diff [ i ] > diff [ j ] ) { Console . Write ( arr [ i ] + " ▁ " ) ; i ++ ; } else { Console . Write ( arr [ j ] + " ▁ " ) ; j -- ; } k -- ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; int k = 3 ; int n = arr . Length ; kStrongest ( arr , n , k ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j, k
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool sorting_possible ( int [ ] a , int [ ] b , int n ) { bool sorted = true ; int type1 = 0 , type0 = 0 , i ; for ( i = 1 ; i < n ; i ++ ) { if ( a [ i ] < a [ i - 1 ] ) { sorted = false ; break ; } } for ( i = 0 ; i < n ; i ++ ) { if ( b [ i ] == 0 ) type0 ++ ; else type1 ++ ; } if ( sorted ) return true ; else if ( type1 == n type0 == n ) return false ; else return true ; } public static void Main ( String [ ] args ) { int [ ] a = { 15 , 1 , 2 , 17 , 6 } ; int [ ] b = { 1 , 1 , 0 , 1 , 1 } ; int n = a . Length ; bool res = sorting_possible ( a , b , n ) ; if ( res ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i, type0, type1
Iterator variables: i
Boolean variables: sorted
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class Pair { public int first , second ; public Pair ( int first , int second ) { this . first = first ; this . second = second ; } } class GFG { static int infi = 1000000000 ; class Node { public int vertexNumber ; public List < Pair > children ; public Node ( int vertexNumber ) { this . vertexNumber = vertexNumber ; children = new List < Pair > ( ) ; } public void Add_child ( int vNumber , int length ) { Pair p = new Pair ( vNumber , length ) ; children . Add ( p ) ; } } static int [ ] dijkstraDist ( List < Node > g , int s , int [ ] path ) { int [ ] dist = new int [ g . Count ] ; bool [ ] visited = new bool [ g . Count ] ; for ( int i = 0 ; i < g . Count ; i ++ ) { visited [ i ] = false ; path [ i ] = - 1 ; dist [ i ] = infi ; } dist [ s ] = 0 ; path [ s ] = - 1 ; int current = s ; HashSet < int > sett = new HashSet < int > ( ) ; while ( true ) { visited [ current ] = true ; for ( int i = 0 ; i < g [ current ] . children . Count ; i ++ ) { int v = g [ current ] . children [ i ] . first ; if ( visited [ v ] ) continue ; sett . Add ( v ) ; int alt = dist [ current ] + g [ current ] . children [ i ] . second ; if ( alt < dist [ v ] ) { dist [ v ] = alt ; path [ v ] = current ; } } sett . Remove ( current ) ; if ( sett . Count == 0 ) break ; int minDist = infi ; int index = 0 ; foreach ( int a in sett ) { if ( dist [ a ] < minDist ) { minDist = dist [ a ] ; index = a ; } } current = index ; } return dist ; } void printPath ( int [ ] path , int i , int s ) { if ( i != s ) { if ( path [ i ] == - 1 ) { Console . WriteLine ( " Path ▁ not ▁ found ! ! " ) ; return ; } printPath ( path , path [ i ] , s ) ; Console . WriteLine ( path [ i ] + " ▁ " ) ; } } public static void Main ( string [ ] args ) { List < Node > v = new List < Node > ( ) ; int n = 4 , s = 0 ; for ( int i = 0 ; i < n ; i ++ ) { Node a = new Node ( i ) ; v . Add ( a ) ; } v [ 0 ] . Add_child ( 1 , 1 ) ; v [ 0 ] . Add_child ( 2 , 4 ) ; v [ 1 ] . Add_child ( 2 , 2 ) ; v [ 1 ] . Add_child ( 3 , 6 ) ; v [ 2 ] . Add_child ( 3 , 3 ) ; int [ ] path = new int [ v . Count ] ; int [ ] dist = dijkstraDist ( v , s , path ) ; for ( int i = 0 ; i < dist . Length ; i ++ ) { if ( dist [ i ] == infi ) { Console . Write ( " { 0 } ▁ and ▁ { 1 } ▁ are ▁ not ▁ " + " connected STRNEWLINE " , i , s ) ; continue ; } Console . Write ( " Distance ▁ of ▁ { 0 } th ▁ vertex ▁ " + " from ▁ source ▁ vertex ▁ { 1 } ▁ is : ▁ { 2 } STRNEWLINE " , i , s , dist [ i ] ) ; } } }

Index/key variables: a, current, i, s, v
Accumulator variables: i
Iterator variables: a, i
Class/struct names: GFG, Node, Pair
C# program:
using System ; using System . Collections . Generic ; class GFG { public static void maximizeval10 ( int [ ] a , int n , int k ) { int increments = 0 ; int ans = 0 ; List < int > v = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { ans += ( a [ i ] / 10 ) ; if ( a [ i ] == 1000 ) continue ; else { v . Add ( 10 - a [ i ] % 10 ) ; increments += ( 100 - ( ( a [ i ] ) / 10 ) - 1 ) ; } } v . Sort ( ) ; int sum = 0 ; for ( int i = 0 ; i < v . Count ; i ++ ) { sum += v [ i ] ; if ( sum <= k ) { ans ++ ; } else break ; } if ( sum < k ) { int remaining = k - sum ; ans += Math . Min ( increments , remaining / 10 ) ; } Console . Write ( ans ) ; } public static void Main ( String [ ] args ) { int N = 4 ; int X = 6 ; int [ ] A = { 4 , 8 , 8 , 8 } ; maximizeval10 ( A , N , X ) ; } }

Index/key variables: i
Accumulator variables: ans, i, increments, sum
Iterator variables: i
Class/struct names: GFG