dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int range_sum ( int [ ] arr , int a , int b ) { int sum = 0 ; if ( a - 2 < 0 ) sum = arr [ b - 1 ] ; else sum = arr [ b - 1 ] - arr [ a - 2 ] ; return sum ; } static void precompute_sum ( int [ ] arr , int [ ] brr ) { int N = ( int ) arr . Length ; for ( int i = 1 ; i < N ; i ++ ) { arr [ i ] = arr [ i ] + arr [ i - 1 ] ; brr [ i ] = brr [ i ] + brr [ i - 1 ] ; } } static void find_sum ( int [ ] arr , int q , int [ , ] Queries ) { int [ ] brr = new int [ arr . Length ] ; arr . CopyTo ( brr , 0 ) ; int N = ( int ) arr . Length ; Array . Sort ( brr ) ; precompute_sum ( arr , brr ) ; for ( int i = 0 ; i < q ; i ++ ) { int m = Queries [ i , 0 ] ; int a = Queries [ i , 1 ] ; int b = Queries [ i , 2 ] ; if ( m == 1 ) { Console . Write ( range_sum ( arr , a , b ) + " ▁ " ) ; } else if ( m == 2 ) { Console . Write ( range_sum ( brr , a , b ) + " ▁ " ) ; } } } public static void Main ( String [ ] args ) { int [ ] arr = { 0 , 6 , 4 , 2 , 7 , 2 , 7 } ; int Q = 1 ; int [ , ] Queries = { { 2 , 3 , 6 } } ; find_sum ( arr , Q , Queries ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int lower_bound ( int [ ] a , int low , int high , int element ) { while ( low < high ) { int middle = low + ( high - low ) / 2 ; if ( element > a [ middle ] ) low = middle + 1 ; else high = middle ; } return low ; } static int XorSum ( int [ ] A , int [ ] B , int N ) { int maxBit = 29 ; int ans = 0 ; for ( int k = 0 ; k < maxBit ; k ++ ) { int [ ] C = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { C [ i ] = B [ i ] % ( 1 << ( k + 1 ) ) ; } Array . Sort ( C ) ; long count = 0 ; long l , r ; for ( int i = 0 ; i < N ; i ++ ) { int x = A [ i ] % ( 1 << ( k + 1 ) ) ; l = lower_bound ( C , 0 , N , ( 1 << k ) - x ) ; r = lower_bound ( C , 0 , N , ( 1 << k ) * 2 - x ) ; count += ( r - l ) ; l = lower_bound ( C , 0 , N , ( 1 << k ) * 3 - x ) ; r = lower_bound ( C , 0 , N , ( 1 << k ) * 4 - x ) ; count += ( r - l ) ; } if ( ( count & 1 ) != 0 ) ans += ( 1 << k ) ; } 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 . Write ( XorSum ( A , B , N ) + " STRNEWLINE " ) ; } }

Index/key variables: N, i, middle
Accumulator variables: ans, count, i, k
Iterator variables: i, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int findCount ( int [ ] arr , int N , int K ) { Array . Sort ( arr ) ; int result = 1 ; int cur_max = arr [ 0 ] ; int cur_min = arr [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { cur_max = arr [ i ] ; if ( cur_max - cur_min > K ) { result ++ ; cur_max = arr [ i ] ; cur_min = arr [ i ] ; } } return result ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 10 , 8 , 3 , 9 } ; int K = 3 ; int N = arr . Length ; Console . Write ( findCount ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: i, result
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findTriplets ( int [ ] arr , int n ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int x = 0 ; x < n ; x ++ ) { if ( mp . ContainsKey ( arr [ x ] ) ) { mp [ arr [ x ] ] ++ ; } else { mp [ arr [ x ] ] = 1 ; } } List < Tuple < int , int > > pq = new List < Tuple < int , int > > ( ) ; int cnt = 0 ; foreach ( KeyValuePair < int , int > pa in mp ) pq . Add ( new Tuple < int , int > ( pa . Value , pa . Key ) ) ; List < List < int > > ans = new List < List < int > > ( ) ; pq . Sort ( ) ; pq . Reverse ( ) ; while ( pq . Count >= 3 ) { Tuple < int , int > [ ] ar = new Tuple < int , int > [ 3 ] ; for ( int x = 0 ; x < 3 ; x ++ ) { ar [ x ] = pq [ 0 ] ; pq . RemoveAt ( 0 ) ; } ans . Add ( new List < int > ( ) ) ; ans [ cnt ] . Add ( ar [ 0 ] . Item2 ) ; ans [ cnt ] . Add ( ar [ 1 ] . Item2 ) ; ans [ cnt ] . Add ( ar [ 2 ] . Item2 ) ; for ( int x = 0 ; x < 3 ; x ++ ) { ar [ x ] = new Tuple < int , int > ( ar [ x ] . Item1 - 1 , ar [ x ] . Item2 ) ; if ( ar [ x ] . Item1 != 0 ) { pq . Add ( ar [ x ] ) ; pq . Sort ( ) ; pq . Reverse ( ) ; } } cnt ++ ; } Console . Write ( " Maximum ▁ number ▁ of ▁ possible ▁ triples : ▁ " ) ; Console . WriteLine ( ans . Count ) ; foreach ( List < int > pa in ans ) { foreach ( int v in pa ) Console . Write ( v + " ▁ " ) ; Console . WriteLine ( ) ; } } static void Main ( ) { int [ ] arr = { 2 , 2 , 3 , 3 , 4 , 4 , 4 , 4 , 5 } ; int n = arr . Length ; findTriplets ( arr , n ) ; } }

Index/key variables: cnt, x
Accumulator variables: cnt, x
Iterator variables: pa, v, x
Class/struct names: GFG
C# program:
using System ; class GFG { static void rearrange ( int [ ] a ) { int i = 0 , j = a . Length - 1 ; int min = 0 , k , x = 0 , temp ; while ( i < j ) { for ( k = i ; k <= j ; k ++ ) { if ( a [ k ] < a [ min ] ) min = k ; } if ( x % 2 == 0 ) { temp = a [ i ] ; a [ i ] = a [ min ] ; a [ min ] = temp ; i ++ ; min = i ; } else { temp = a [ j ] ; a [ j ] = a [ min ] ; a [ min ] = temp ; j -- ; min = j ; } x ++ ; } for ( i = 0 ; i < a . Length ; i ++ ) Console . Write ( a [ i ] + " ▁ " ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 1 , 3 , 3 , 4 , 5 } ; rearrange ( arr ) ; } }

Index/key variables: i, j, k, min
Accumulator variables: i, j, k, x
Iterator variables: i, k
Class/struct names: GFG
C# program:
using System ; class GFG { static void redistribute ( int [ ] arr , int n , int x ) { Array . Sort ( arr ) ; Array . Reverse ( arr ) ; int i , sum = 0 ; for ( i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; if ( sum / ( i + 1 ) < x ) { Console . Write ( i + " STRNEWLINE " ) ; break ; } } if ( i == n ) Console . Write ( n + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 1 , 2 , 1 } ; int x = 3 ; redistribute ( arr , 4 , x ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void final_element ( int [ ] arr , int n ) { List < int > heap = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) heap . Add ( arr [ i ] ) ; while ( heap . Count > 1 ) { heap . Sort ( ) ; heap . Reverse ( ) ; int X = heap [ 0 ] ; heap . RemoveAt ( 0 ) ; int Y = heap [ 0 ] ; heap . RemoveAt ( 0 ) ; if ( X != Y ) { int diff = Math . Abs ( X - Y ) ; heap . Add ( diff ) ; } } if ( heap . Count == 1 ) { heap . Sort ( ) ; heap . Reverse ( ) ; Console . Write ( heap [ 0 ] ) ; } else { Console . Write ( - 1 ) ; } } static void Main ( ) { int [ ] arr = { 3 , 5 , 2 , 7 } ; int n = arr . Length ; final_element ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSumArrangement ( int [ ] A , int [ , ] R , int N , int M ) { int [ ] count = new int [ N ] ; int i ; for ( i = 0 ; i < M ; ++ i ) { int l = R [ i , 0 ] , r = R [ i , 1 ] + 1 ; l -- ; r -- ; count [ l ] ++ ; if ( r < N ) count [ r ] -- ; } for ( i = 1 ; i < N ; ++ i ) { count [ i ] += count [ i - 1 ] ; } int ans = 0 ; Array . Sort ( count ) ; Array . Sort ( A ) ; for ( i = N - 1 ; i >= 0 ; -- i ) { ans += A [ i ] * count [ i ] ; } return ans ; } public static void Main ( String [ ] args ) { int [ ] A = { 2 , 6 , 10 , 1 , 5 , 6 } ; int [ , ] R = { { 1 , 3 } , { 4 , 6 } , { 3 , 4 } } ; int N = A . Length ; int M = R . GetLength ( 0 ) ; Console . Write ( maxSumArrangement ( A , R , N , M ) ) ; } }

Index/key variables: N, i, l, r
Accumulator variables: ans, l, r
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int partition ( List < String > objects , int l , int r , Dictionary < String , int > hash ) { int j = l - 1 ; String temp ; int last_element = hash [ objects [ r ] ] ; for ( int i = l ; i < r ; i ++ ) { if ( hash [ objects [ i ] ] <= last_element ) { j ++ ; temp = objects [ i ] ; objects [ i ] = objects [ j ] ; objects [ j ] = temp ; } } j ++ ; temp = objects [ r ] ; objects [ r ] = objects [ j ] ; objects [ j ] = temp ; return j ; } static void quicksort ( List < String > objects , int l , int r , Dictionary < String , int > hash ) { if ( l < r ) { int mid = partition ( objects , l , r , hash ) ; quicksort ( objects , l , mid - 1 , hash ) ; quicksort ( objects , mid + 1 , r , hash ) ; } } static void sortObj ( List < String > objects ) { Dictionary < String , int > hash = new Dictionary < String , int > ( ) ; hash . Add ( " blue " , 1 ) ; hash . Add ( " red " , 2 ) ; hash . Add ( " yellow " , 3 ) ; quicksort ( objects , 0 , objects . Count - 1 , hash ) ; for ( int i = 0 ; i < objects . Count ; i ++ ) Console . Write ( objects [ i ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { List < String > objects = new List < String > { " red " , " blue " , " red " , " yellow " , " blue " } ; sortObj ( objects ) ; } }

Index/key variables: i, j, r
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int getMax ( int [ ] inputArray ) { int maxValue = inputArray [ 0 ] ; for ( int i = 1 ; i < inputArray . Length ; i ++ ) { if ( inputArray [ i ] > maxValue ) { maxValue = inputArray [ i ] ; } } return maxValue ; } static int minSteps ( int [ ] arr , int n ) { int maxVal = getMax ( arr ) ; return maxVal ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 4 } ; int n = arr . Length ; Console . WriteLine ( minSteps ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxWater ( int [ ] height , int n ) { int max = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { int current = ( Math . Min ( height [ i ] , height [ j ] ) * ( j - i - 1 ) ) ; max = Math . Max ( max , current ) ; } } return max ; } static public void Main ( ) { int [ ] height = { 2 , 1 , 3 , 4 , 6 , 5 } ; int n = height . Length ; Console . WriteLine ( maxWater ( height , 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 max_element ( int [ ] a ) { int m = a [ 0 ] ; for ( int i = 0 ; i < a . Length ; i ++ ) m = Math . Max ( a [ i ] , m ) ; return m ; } static bool checkDivisors ( int [ ] a , int n ) { int X = max_element ( a ) ; List < int > b = new List < int > ( ) ; for ( int i = 1 ; i * i <= X ; i ++ ) { if ( X % i == 0 ) { b . Add ( i ) ; if ( X / i != i ) b . Add ( X / i ) ; } } if ( b . Count != n ) return false ; Array . Sort ( a ) ; b . Sort ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( b [ i ] != a [ i ] ) return false ; } return true ; } public static void Main ( String [ ] args ) { int [ ] arr = { 8 , 1 , 2 , 12 , 48 , 6 , 4 , 24 , 16 , 3 } ; int N = arr . Length ; if ( checkDivisors ( arr , N ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { class pair { public int first , second ; public pair ( int a , int b ) { first = a ; second = b ; } } class sortHelper : IComparer { int IComparer . Compare ( object a , object b ) { pair first = ( pair ) a ; pair second = ( pair ) b ; return first . first - second . first ; } } static void findKthNode ( int [ ] u , int [ ] v , int n , int [ ] val , int V , int k ) { ArrayList g = new ArrayList ( ) ; for ( int i = 0 ; i < V ; i ++ ) g . Add ( new ArrayList ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { ( ( ArrayList ) g [ u [ i ] ] ) . Add ( new pair ( val [ v [ i ] ] , v [ i ] ) ) ; ( ( ArrayList ) g [ v [ i ] ] ) . Add ( new pair ( val [ u [ i ] ] , u [ i ] ) ) ; } for ( int i = 0 ; i < V ; i ++ ) { if ( ( ( ArrayList ) g [ i ] ) . Count > 0 ) { ArrayList tmp = ( ArrayList ) g [ i ] ; tmp . Sort ( new sortHelper ( ) ) ; g [ i ] = tmp ; } if ( k <= ( ( ArrayList ) g [ i ] ) . Count ) Console . Write ( ( ( pair ) ( ( ArrayList ) g [ i ] ) [ ( ( ArrayList ) g [ i ] ) . Count - k ] ) . second + " STRNEWLINE " ) ; else Console . Write ( " - 1 STRNEWLINE " ) ; } return ; } public static void Main ( string [ ] args ) { int V = 3 ; int [ ] val = { 2 , 4 , 3 } ; int [ ] u = { 0 , 0 , 1 } ; int [ ] v = { 2 , 1 , 2 } ; int n = u . Length ; int k = 2 ; findKthNode ( u , v , n , val , V , k ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, pair, sortHelper
C# program:
using System ; class GFG { static int mod ( int x ) { if ( x >= 0 ) return x ; return - x ; } static void findSquare ( int n ) { int [ , ] points = new int [ 4 , 2 ] { { 1 , 2 } , { - 3 , 4 } , { 1 , 78 } , { - 3 , - 7 } } ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int x , y ; x = points [ i , 0 ] ; y = points [ i , 1 ] ; a [ i ] = Math . Max ( mod ( x ) , mod ( y ) ) ; } Array . Sort ( a ) ; int index = ( int ) ( n / 2 - 1 ) ; Console . WriteLine ( " Minimum ▁ M ▁ required ▁ is : ▁ " + a [ index ] ) ; } public static void Main ( String [ ] args ) { int N ; N = 4 ; findSquare ( N ) ; } }

Index/key variables: i, index, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findpath ( int [ , ] graph , int n ) { List < int > numofadj = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) numofadj . Add ( accumulate ( graph , i , 0 ) ) ; int startPoint = 0 , numofodd = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( numofadj [ i ] % 2 == 1 ) { numofodd ++ ; startPoint = i ; } } if ( numofodd > 2 ) { Console . WriteLine ( " No ▁ Solution " ) ; return ; } Stack < int > stack = new Stack < int > ( ) ; List < int > path = new List < int > ( ) ; int cur = startPoint ; while ( stack . Count != 0 || accumulate ( graph , cur , 0 ) != 0 ) { if ( accumulate ( graph , cur , 0 ) == 0 ) { path . Add ( cur ) ; cur = stack . Pop ( ) ; } else { for ( int i = 0 ; i < n ; i ++ ) { if ( graph [ cur , i ] == 1 ) { stack . Push ( cur ) ; graph [ cur , i ] = 0 ; graph [ i , cur ] = 0 ; cur = i ; break ; } } } } foreach ( int ele in path ) Console . Write ( ele + " ▁ - > ▁ " ) ; Console . WriteLine ( cur ) ; } static int accumulate ( int [ , ] matrix , int row , int sum ) { int [ ] arr = GetRow ( matrix , row ) ; foreach ( int i in arr ) sum += i ; return sum ; } public static int [ ] GetRow ( int [ , ] matrix , int row ) { var rowLength = matrix . GetLength ( 1 ) ; var rowVector = new int [ rowLength ] ; for ( var i = 0 ; i < rowLength ; i ++ ) rowVector [ i ] = matrix [ row , i ] ; return rowVector ; } public static void Main ( String [ ] args ) { int [ , ] graph1 = { { 0 , 1 , 0 , 0 , 1 } , { 1 , 0 , 1 , 1 , 0 } , { 0 , 1 , 0 , 1 , 0 } , { 0 , 1 , 1 , 0 , 0 } , { 1 , 0 , 0 , 0 , 0 } } ; int n = graph1 . GetLength ( 0 ) ; findpath ( graph1 , n ) ; int [ , ] graph2 = { { 0 , 1 , 0 , 1 , 1 } , { 1 , 0 , 1 , 0 , 1 } , { 0 , 1 , 0 , 1 , 1 } , { 1 , 1 , 1 , 0 , 0 } , { 1 , 0 , 1 , 0 , 0 } } ; n = graph2 . GetLength ( 0 ) ; findpath ( graph2 , n ) ; int [ , ] graph3 = { { 0 , 1 , 0 , 0 , 1 } , { 1 , 0 , 1 , 1 , 1 } , { 0 , 1 , 0 , 1 , 0 } , { 0 , 1 , 1 , 0 , 1 } , { 1 , 1 , 0 , 1 , 0 } } ; n = graph3 . GetLength ( 0 ) ; findpath ( graph3 , n ) ; } }

Index/key variables: i, rowLength
Accumulator variables: i, numofodd, sum
Iterator variables: ele, i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minSum ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int x = arr [ ( int ) ( n / 2 ) ] ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += Math . Abs ( arr [ i ] - x ) ; return sum ; } static void Main ( ) { int [ ] arr = { 1 , 3 , 9 , 3 , 6 } ; int n = arr . Length ; Console . WriteLine ( minSum ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void odd_even ( int [ ] arr , int n ) { List < int > odd_indexes = new List < int > ( ) ; List < int > even_indexes = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) odd_indexes . Add ( arr [ i ] ) ; else even_indexes . Add ( arr [ i ] ) ; } odd_indexes . Sort ( ) ; even_indexes . Sort ( ) ; for ( int i = 0 ; i < odd_indexes . Count ; i ++ ) Console . Write ( odd_indexes [ i ] + " ▁ " ) ; for ( int i = 0 ; i < even_indexes . Count ; i ++ ) Console . Write ( even_indexes [ i ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 2 , 7 , 6 , 8 } ; int n = arr . Length ; odd_even ( 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 countPairs ( int [ ] a , int n ) { Dictionary < int , int > map = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! map . ContainsKey ( a [ i ] ) ) map . Add ( a [ i ] , 1 ) ; } int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( map [ a [ i ] ] < 1 ) continue ; int cur = 1 ; while ( cur <= a [ i ] ) cur <<= 1 ; if ( map . ContainsKey ( cur - a [ i ] ) ) { if ( cur - a [ i ] == a [ i ] && map [ a [ i ] ] == 1 ) continue ; count ++ ; map [ cur - a [ i ] ] = map [ cur - a [ i ] ] - 1 ; map [ a [ i ] ] = map [ a [ i ] ] - 1 ; } } return count ; } public static void Main ( String [ ] args ) { int [ ] a = { 3 , 11 , 14 , 5 , 13 } ; int n = a . Length ; Console . WriteLine ( countPairs ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countMaxPos ( int [ ] arr ) { int n = arr . Length ; Dictionary < int , int > map = new Dictionary < int , int > ( ) ; foreach ( int x in arr ) { if ( map . ContainsKey ( x ) ) map [ x ] = map [ x ] + 1 ; else map . Add ( x , 1 ) ; } int max_freq = 0 ; foreach ( KeyValuePair < int , int > entry in map ) max_freq = Math . Max ( max_freq , entry . Value ) ; return n - max_freq ; } public static void Main ( String [ ] args ) { int [ ] arr = { 20 , 30 , 10 , 50 , 40 } ; Console . WriteLine ( countMaxPos ( arr ) ) ; } }

Index/key variables: x
Iterator variables: entry, x
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void sortMultiples ( int [ ] arr , int n , int x ) { List < int > v = new List < int > ( ) ; int i ; for ( i = 0 ; i < n ; i ++ ) if ( arr [ i ] % x == 0 ) v . Add ( arr [ i ] ) ; v . Sort ( ) ; int j = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % x == 0 ) arr [ i ] = v [ j ++ ] ; } } public static void Main ( ) { int [ ] arr = { 125 , 3 , 15 , 6 , 100 , 5 } ; int x = 5 ; int n = arr . Length ; sortMultiples ( arr , n , x ) ; for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minimumIncrease ( int a , int b , int c ) { int [ ] arr = { a , b , c } ; Array . Sort ( arr ) ; if ( arr [ 0 ] + arr [ 1 ] >= arr [ 2 ] ) return 0 ; else return arr [ 2 ] - ( arr [ 0 ] + arr [ 1 ] ) ; } public static void Main ( ) { int a = 3 , b = 5 , c = 10 ; Console . Write ( minimumIncrease ( a , b , c ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int absSumDidd ( int [ ] a ) { Array . Sort ( a ) ; int midValue = a [ a . Length / 2 ] ; int sum = 0 ; for ( int i = 0 ; i < a . Length ; i ++ ) { sum = sum + Math . Abs ( a [ i ] - midValue ) ; } return sum ; } public static void Main ( ) { int [ ] arr = { 5 , 11 , 14 , 10 , 17 , 15 } ; Console . Write ( absSumDidd ( arr ) ) ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printRLE ( String s ) { for ( int i = 0 ; i < s . Length - 1 ; i ++ ) { int count = 1 ; while ( s [ i ] == s [ i + 1 ] ) { i ++ ; count ++ ; if ( i + 1 == s . Length ) break ; } Console . Write ( s [ i ] + " " + count + " ▁ " ) ; } Console . WriteLine ( ) ; } public static void Main ( String [ ] args ) { printRLE ( " GeeeEEKKKss " ) ; printRLE ( " ccccOddEEE " ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int shortestChainLen ( String start , String target , HashSet < String > D ) { if ( start == target ) return 0 ; if ( ! D . Contains ( target ) ) return 0 ; int level = 0 , wordlength = start . Length ; List < String > Q = new List < String > ( ) ; Q . Add ( start ) ; while ( Q . Count != 0 ) { ++ level ; int sizeofQ = Q . Count ; for ( int i = 0 ; i < sizeofQ ; ++ i ) { char [ ] word = Q [ 0 ] . ToCharArray ( ) ; Q . RemoveAt ( 0 ) ; for ( int pos = 0 ; pos < wordlength ; ++ pos ) { char orig_char = word [ pos ] ; for ( char c = ' a ' ; c <= ' z ' ; ++ c ) { word [ pos ] = c ; if ( String . Join ( " " , word ) . Equals ( target ) ) return level + 1 ; if ( ! D . Contains ( String . Join ( " " , word ) ) ) continue ; D . Remove ( String . Join ( " " , word ) ) ; Q . Add ( String . Join ( " " , word ) ) ; } word [ pos ] = orig_char ; } } } return 0 ; } public static void Main ( String [ ] args ) { HashSet < String > D = new HashSet < String > ( ) ; D . Add ( " poon " ) ; D . Add ( " plee " ) ; D . Add ( " same " ) ; D . Add ( " poie " ) ; D . Add ( " plie " ) ; D . Add ( " poin " ) ; D . Add ( " plea " ) ; String start = " toon " ; String target = " plea " ; Console . Write ( " Length ▁ of ▁ shortest ▁ chain ▁ is : ▁ " + shortestChainLen ( start , target , D ) ) ; } }

Index/key variables: pos
Iterator variables: c, i, pos
Class/struct names: GFG
C# program:
using System ; class GFG { static int root ( int [ ] arr , int i ) { while ( arr [ i ] != i ) { arr [ i ] = arr [ arr [ i ] ] ; i = arr [ i ] ; } return i ; } static void weighted_union ( int [ ] arr , int [ ] rank , int a , int b ) { int root_a = root ( arr , a ) ; int root_b = root ( arr , b ) ; if ( rank [ root_a ] < rank [ root_b ] ) { arr [ root_a ] = arr [ root_b ] ; rank [ root_b ] += rank [ root_a ] ; } else { arr [ root_b ] = arr [ root_a ] ; rank [ root_a ] += rank [ root_b ] ; } } static Boolean areSame ( int [ ] arr , int a , int b ) { return ( root ( arr , a ) == root ( arr , b ) ) ; } static void query ( int type , int x , int y , int [ ] arr , int [ ] rank ) { if ( type == 1 ) { if ( areSame ( arr , x , y ) == true ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } else if ( type == 2 ) { if ( areSame ( arr , x , y ) == false ) weighted_union ( arr , rank , x , y ) ; } } public static void Main ( String [ ] args ) { int n = 7 ; int [ ] arr = new int [ n ] ; int [ ] rank = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = i ; rank [ i ] = 1 ; } query ( 1 , 0 , 1 , arr , rank ) ; query ( 2 , 0 , 1 , arr , rank ) ; query ( 2 , 1 , 2 , arr , rank ) ; query ( 1 , 0 , 2 , arr , rank ) ; query ( 2 , 0 , 2 , arr , rank ) ; query ( 2 , 2 , 3 , arr , rank ) ; query ( 2 , 3 , 4 , arr , rank ) ; query ( 1 , 0 , 5 , arr , rank ) ; query ( 2 , 4 , 5 , arr , rank ) ; query ( 2 , 5 , 6 , arr , rank ) ; query ( 1 , 2 , 6 , arr , rank ) ; } }

Index/key variables: i, n, root_a, root_b
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG