dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { public class Interval { public int s ; public int e ; public Interval ( int a , int b ) { s = a ; e = b ; } } ; class sortHelper : IComparer { int IComparer . Compare ( object a , object b ) { Interval first = ( Interval ) a ; Interval second = ( Interval ) b ; return first . s - second . s ; } } static int kthSmallestNum ( ArrayList merged , int k ) { int n = merged . Count ; for ( int j = 0 ; j < n ; j ++ ) { if ( k <= Math . Abs ( ( ( Interval ) merged [ j ] ) . e - ( ( Interval ) merged [ j ] ) . s + 1 ) ) return ( ( ( Interval ) merged [ j ] ) . s + k - 1 ) ; k = k - Math . Abs ( ( ( Interval ) merged [ j ] ) . e - ( ( Interval ) merged [ j ] ) . s + 1 ) ; } if ( k != 0 ) return - 1 ; return 0 ; } static ArrayList mergeIntervals ( ArrayList merged , Interval [ ] arr , int n ) { Array . Sort ( arr , new sortHelper ( ) ) ; merged . Add ( ( Interval ) arr [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) { Interval prev = ( Interval ) merged [ merged . Count - 1 ] ; Interval curr = arr [ i ] ; if ( ( curr . s >= prev . s && curr . s <= prev . e ) && ( curr . e > prev . e ) ) { ( ( Interval ) merged [ merged . Count - 1 ] ) . e = ( ( Interval ) curr ) . e ; } else { merged . Add ( curr ) ; } } return merged ; } public static void Main ( string [ ] args ) { Interval [ ] arr = { new Interval ( 2 , 6 ) , new Interval ( 4 , 7 ) } ; int n = arr . Length ; int [ ] query = { 5 , 8 } ; int q = query . Length ; ArrayList merged = new ArrayList ( ) ; merged = mergeIntervals ( merged , arr , n ) ; for ( int i = 0 ; i < q ; i ++ ) Console . WriteLine ( kthSmallestNum ( merged , query [ i ] ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG, Interval, sortHelper
C# program:
using System ; class Country { public static void countCountries ( int [ ] ans , int N ) { int total_countries = 0 , i = 0 ; while ( i < N ) { int curr_size = ans [ i ] ; int num = ans [ i ] ; while ( num > 0 ) { if ( ans [ i ] != curr_size ) { Console . Write ( " Invalid ▁ Answer STRNEWLINE " ) ; return ; } else num -- ; i ++ ; } total_countries ++ ; } Console . Write ( " There ▁ are ▁ " + total_countries + " ▁ distinct ▁ companies ▁ in ▁ the ▁ group . STRNEWLINE " ) ; } public static void Main ( ) { int [ ] ans = { 1 , 1 , 2 , 2 , 4 , 4 , 4 , 4 } ; int n = 8 ; countCountries ( ans , n ) ; } }

Index/key variables: i
Accumulator variables: i, num, total_countries
Class/struct names: Country
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int data ) { this . data = data ; left = right = null ; } } public class Level { public int maxlevel = 0 ; } public class BinaryTree { public Node root ; public Node result ; public virtual void deepestLeftLeafUtil ( Node node , int lvl , Level level , bool isLeft ) { if ( node == null ) { return ; } if ( isLeft != false && node . left == null && node . right == null && lvl > level . maxlevel ) { result = node ; level . maxlevel = lvl ; } deepestLeftLeafUtil ( node . left , lvl + 1 , level , true ) ; deepestLeftLeafUtil ( node . right , lvl + 1 , level , false ) ; } public virtual void deepestLeftLeaf ( Node node ) { Level level = new Level ( ) ; deepestLeftLeafUtil ( node , 0 , level , false ) ; } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . right . left = new Node ( 5 ) ; tree . root . right . right = new Node ( 6 ) ; tree . root . right . left . right = new Node ( 7 ) ; tree . root . right . right . right = new Node ( 8 ) ; tree . root . right . left . right . left = new Node ( 9 ) ; tree . root . right . right . right . right = new Node ( 10 ) ; tree . deepestLeftLeaf ( tree . root ) ; if ( tree . result != null ) { Console . WriteLine ( " The ▁ deepest ▁ left ▁ child ▁ is ▁ " + tree . result . data ) ; } else { Console . WriteLine ( " There ▁ is ▁ no ▁ left ▁ leaf ▁ in ▁ the ▁ given ▁ tree " ) ; } } }

Class/struct names: BinaryTree, Level, Node
C# program:
using System ; class GFG { public static bool check_elements ( int [ ] arr , int n , int A , int B ) { int range = B - A ; for ( int i = 0 ; i < n ; i ++ ) { if ( Math . Abs ( arr [ i ] ) >= A && Math . Abs ( arr [ i ] ) <= B ) { int z = Math . Abs ( arr [ i ] ) - A ; if ( arr [ z ] > 0 ) { arr [ z ] = arr [ z ] * - 1 ; } } } int count = 0 ; for ( int i = 0 ; i <= range && i < n ; i ++ ) { if ( arr [ i ] > 0 ) return false ; else count ++ ; } if ( count != ( range + 1 ) ) return false ; return true ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 4 , 5 , 2 , 7 , 8 , 3 } ; int n = arr . Length ; int A = 2 , B = 5 ; if ( check_elements ( arr , n , A , B ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i, z
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int findMinRec ( int [ ] A , int n ) { if ( n == 1 ) return A [ 0 ] ; return Math . Min ( A [ n - 1 ] , findMinRec ( A , n - 1 ) ) ; } static public void Main ( ) { int [ ] A = { 1 , 4 , 45 , 6 , - 50 , 10 , 2 } ; int n = A . Length ; Console . WriteLine ( findMinRec ( A , n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPossible ( int [ ] arr , int n , int m , int curr_min ) { int studentsRequired = 1 ; int curr_sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > curr_min ) return false ; if ( curr_sum + arr [ i ] > curr_min ) { studentsRequired ++ ; curr_sum = arr [ i ] ; if ( studentsRequired > m ) return false ; } else curr_sum += arr [ i ] ; } return true ; } static int findPages ( int [ ] arr , int n , int m ) { long sum = 0 ; if ( n < m ) return - 1 ; for ( int i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; int start = 0 , end = ( int ) sum ; int result = int . MaxValue ; while ( start <= end ) { int mid = ( start + end ) / 2 ; if ( isPossible ( arr , n , m , mid ) ) { result = mid ; end = mid - 1 ; } else start = mid + 1 ; } return result ; } static public void Main ( ) { int [ ] arr = { 12 , 34 , 67 , 90 } ; int n = arr . Length ; Console . WriteLine ( " Minimum ▁ number ▁ of ▁ pages ▁ = ▁ " + findPages ( arr , n , m ) ) ; } }

Index/key variables: i
Accumulator variables: curr_sum, i, studentsRequired, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } public class BinaryTree { public Node root ; public virtual int minimumDepth ( ) { return minimumDepth ( root ) ; } public virtual int minimumDepth ( Node root ) { if ( root == null ) { return 0 ; } if ( root . left == null && root . right == null ) { return 1 ; } if ( root . left == null ) { return minimumDepth ( root . right ) + 1 ; } if ( root . right == null ) { return minimumDepth ( root . left ) + 1 ; } return Math . Min ( minimumDepth ( root . left ) , minimumDepth ( root . right ) ) + 1 ; } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 5 ) ; Console . WriteLine ( " The ▁ minimum ▁ depth ▁ of ▁ binary ▁ tree ▁ is ▁ : ▁ " + tree . minimumDepth ( ) ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { static void maxFreqElements ( int [ ] arr , int N , int K ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( mp . ContainsKey ( arr [ i ] ) ) { mp [ arr [ i ] ] ++ ; } else { mp [ arr [ i ] ] = 1 ; } } while ( K > 0 ) { int max = 0 ; int element = 0 ; foreach ( KeyValuePair < int , int > i in mp ) { if ( i . Value > max ) { max = i . Value ; element = i . Key ; } } Console . Write ( element + " ▁ " ) ; if ( mp . ContainsKey ( element ) ) { mp [ element ] -- ; } else { mp [ element ] = - 1 ; } K -- ; } } static void Main ( ) { int [ ] arr = { 1 , 3 , 2 , 1 , 4 , 1 } ; int N = arr . Length ; int K = 2 ; maxFreqElements ( arr , N , K ) ; } }

Index/key variables: element, i
Accumulator variables: K, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxDiffLargSmallOper ( int [ ] arr , int N , int K ) { int maxDiff = 0 ; Array . Sort ( arr ) ; Array . Reverse ( arr ) ; for ( int i = 0 ; i <= Math . Min ( K , N - 1 ) ; i ++ ) { maxDiff += arr [ i ] ; } return maxDiff ; } public static void Main ( ) { int [ ] arr = new int [ ] { 7 , 7 , 7 , 7 } ; int N = arr . Length ; int K = 1 ; Console . Write ( maxDiffLargSmallOper ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: i, maxDiff
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int minCost ( String s , int [ ] R , int [ ] C , int N ) { char [ ] ch = s . ToCharArray ( ) ; Queue < int > pq = new Queue < int > ( ) ; int flip = 0 ; int cost = 0 ; for ( int i = 0 ; i < N ; i ++ ) { while ( pq . Count > 0 && pq . Peek ( ) < i ) { pq . Dequeue ( ) ; flip -- ; } int cn = ch [ i ] - '0' ; if ( flip % 2 == 1 ) cn = 1 - cn ; if ( cn == 1 ) { flip ++ ; cost += C [ i ] ; pq . Enqueue ( R [ i ] ) ; } } return cost ; } public static void Main ( String [ ] args ) { int N = 4 ; String s = "1010" ; int [ ] R = { 1 , 2 , 2 , 3 } ; int [ ] C = { 3 , 1 , 2 , 3 } ; Console . WriteLine ( minCost ( s , R , C , N ) ) ; } }

Index/key variables: i
Accumulator variables: cost, flip, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public class Node { public int data ; public Node left , right ; } public class qItem { public Node node ; public int depth ; public qItem ( Node node , int depth ) { this . node = node ; this . depth = depth ; } } static int minDepth ( Node root ) { if ( root == null ) return 0 ; Queue < qItem > q = new Queue < qItem > ( ) ; qItem qi = new qItem ( root , 1 ) ; q . Enqueue ( qi ) ; while ( q . Count != 0 ) { qi = q . Peek ( ) ; q . Dequeue ( ) ; Node node = qi . node ; int depth = qi . depth ; if ( node . left == null && node . right == null ) return depth ; if ( node . left != null ) { qi . node = node . left ; qi . depth = depth + 1 ; q . Enqueue ( qi ) ; } if ( node . right != null ) { qi . node = node . right ; qi . depth = depth + 1 ; q . Enqueue ( qi ) ; } } return 0 ; } static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . data = data ; temp . left = temp . right = null ; return temp ; } public static void Main ( String [ ] args ) { Node root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 3 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 5 ) ; Console . WriteLine ( minDepth ( root ) ) ; } }

Class/struct names: GFG, Node, qItem
C# program:
using System ; using System . Collections . Generic ; class GFG { class Pair { public int x ; public int y ; public Pair ( int x , int y ) { this . x = x ; this . y = y ; } } static void MaxDist ( List < Pair > A , int N ) { List < int > V = new List < int > ( ) ; List < int > V1 = new List < int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { V . Add ( A [ i ] . x + A [ i ] . y ) ; V1 . Add ( A [ i ] . x - A [ i ] . y ) ; } V . Sort ( ) ; V1 . Sort ( ) ; int maximum = Math . Max ( ( V [ V . Count - 1 ] - V [ 0 ] ) , ( V1 [ V1 . Count - 1 ] - V1 [ 0 ] ) ) ; Console . WriteLine ( maximum ) ; } public static void Main ( String [ ] args ) { int n = 3 ; List < Pair > al = new List < Pair > ( ) ; Pair p1 = new Pair ( 1 , 2 ) ; al . Add ( p1 ) ; Pair p2 = new Pair ( 2 , 3 ) ; al . Add ( p2 ) ; Pair p3 = new Pair ( 3 , 4 ) ; al . Add ( p3 ) ; MaxDist ( al , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Pair
C# program:
using System ; class GFG { static long dist ( Tuple < int , int > p1 , Tuple < int , int > p2 ) { long x0 = p1 . Item1 - p2 . Item1 ; long y0 = p1 . Item2 - p2 . Item2 ; return x0 * x0 + y0 * y0 ; } static double maxDist ( Tuple < int , int > [ ] p ) { int n = p . Length ; double max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { max = Math . Max ( max , dist ( p [ i ] , p [ j ] ) ) ; } } return Math . Sqrt ( max ) ; } static void Main ( ) { Tuple < int , int > [ ] p = { Tuple . Create ( 4 , 0 ) , Tuple . Create ( 0 , 2 ) , Tuple . Create ( - 1 , - 7 ) , Tuple . Create ( 1 , 10 ) , Tuple . Create ( 2 , - 3 ) , } ; Console . WriteLine ( maxDist ( p ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static void printArr ( int [ ] arr , int n ) { Array . Sort ( arr ) ; if ( arr [ 0 ] == arr [ n - 1 ] ) { Console . Write ( " No STRNEWLINE " ) ; } else { Console . Write ( " Yes STRNEWLINE " ) ; for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } } public static void Main ( ) { int [ ] arr = new int [ 6 ] { 1 , 2 , 2 , 1 , 3 , 1 } ; int N = arr . Length ; printArr ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } public class MinimumTreeHeight { Node root ; int minimumDepth ( ) { return minimumDepth ( root , 0 ) ; } int minimumDepth ( Node root , int level ) { if ( root == null ) return level ; level ++ ; return Math . Min ( minimumDepth ( root . left , level ) , minimumDepth ( root . right , level ) ) ; } public static void Main ( String [ ] args ) { MinimumTreeHeight tree = new MinimumTreeHeight ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 5 ) ; Console . WriteLine ( " The ▁ minimum ▁ depth ▁ of ▁ " + " binary ▁ tree ▁ is ▁ : ▁ " + tree . minimumDepth ( ) ) ; } }

Accumulator variables: level
Class/struct names: MinimumTreeHeight, Node
C# program:
using System ; class GFG { static void maximumSum ( int [ ] a , int [ ] b , int k , int n ) { int i , j ; Array . Sort ( a ) ; Array . Sort ( b ) ; for ( i = 0 , j = n - 1 ; i < k ; i ++ , j -- ) { if ( a [ i ] < b [ j ] ) { int temp = a [ i ] ; a [ i ] = b [ j ] ; b [ j ] = temp ; } else break ; } int sum = 0 ; for ( i = 0 ; i < n ; i ++ ) sum += a [ i ] ; Console . Write ( sum + " STRNEWLINE " ) ; } public static void Main ( ) { int K = 1 ; int [ ] A = { 2 , 3 , 4 } ; int [ ] B = { 6 , 8 , 5 } ; int N = A . Length ; maximumSum ( A , B , K , N ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int max_dist_ele ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int ans = 0 ; int prev = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( prev < ( arr [ i ] - 1 ) ) { ans ++ ; prev = arr [ i ] - 1 ; } else if ( prev < ( arr [ i ] ) ) { ans ++ ; prev = arr [ i ] ; } else if ( prev < ( arr [ i ] + 1 ) ) { ans ++ ; prev = arr [ i ] + 1 ; } } return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 1 , 1 , 8 , 8 , 8 , 9 , 9 } ; int n = arr . Length ; Console . WriteLine ( max_dist_ele ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static void CheckSort ( ArrayList arr , int k , int n ) { ArrayList sortarr = new ArrayList ( arr ) ; sortarr . Sort ( ) ; if ( k == 1 ) Console . Write ( " yes " ) ; else { int flag = 0 ; for ( int i = 0 ; i < n ; i ++ ) { flag = 0 ; for ( int j = i ; j < n ; j += k ) { if ( ( int ) sortarr [ i ] == ( int ) arr [ j ] ) { int tmp = ( int ) arr [ i ] ; arr [ i ] = ( int ) arr [ j ] ; arr [ j ] = tmp ; flag = 1 ; break ; } if ( j + k >= n ) { break ; } } if ( flag == 0 ) { break ; } } if ( flag == 0 ) Console . Write ( " Not ▁ possible ▁ to ▁ sort " ) ; else Console . Write ( " Possible ▁ to ▁ sort " ) ; } } public static void Main ( string [ ] args ) { int k = 3 ; ArrayList arr = new ArrayList ( ) { 1 , 5 , 6 , 9 , 2 , 3 , 5 , 9 } ; int n = arr . Count ; CheckSort ( arr , k , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GfG { public class Node { public int data ; public Node left , right ; } static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . data = data ; temp . left = null ; temp . right = null ; return temp ; } static void replaceNode ( Node node , int level ) { if ( node == null ) return ; node . data = level ; replaceNode ( node . left , level + 1 ) ; replaceNode ( node . right , level + 1 ) ; } static void printInorder ( Node node ) { if ( node == null ) return ; printInorder ( node . left ) ; Console . Write ( node . data + " ▁ " ) ; printInorder ( node . right ) ; } public static void Main ( String [ ] args ) { Node root = new Node ( ) ; root = newNode ( 3 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 5 ) ; root . left . left = newNode ( 1 ) ; root . left . right = newNode ( 4 ) ; Console . WriteLine ( " Before ▁ Replacing ▁ Nodes " ) ; printInorder ( root ) ; replaceNode ( root , 0 ) ; Console . WriteLine ( ) ; Console . WriteLine ( " After ▁ Replacing ▁ Nodes " ) ; printInorder ( root ) ; } }

Class/struct names: GfG, Node
C# program:
using System ; class GFG { public static bool check ( int [ ] arr , int n ) { int modify = 0 ; if ( arr [ n - 1 ] >= arr [ n - 2 ] ) { arr [ n - 1 ] = arr [ n - 2 ] - 1 ; modify ++ ; } if ( arr [ 0 ] <= arr [ 1 ] ) { arr [ 0 ] = arr [ 1 ] + 1 ; modify ++ ; } for ( int i = n - 2 ; i > 0 ; i -- ) { if ( ( arr [ i - 1 ] <= arr [ i ] && arr [ i + 1 ] <= arr [ i ] ) || ( arr [ i - 1 ] >= arr [ i ] && arr [ i + 1 ] >= arr [ i ] ) ) { arr [ i ] = ( arr [ i - 1 ] + arr [ i + 1 ] ) / 2 ; modify ++ ; if ( arr [ i ] == arr [ i - 1 ] arr [ i ] == arr [ i + 1 ] ) return false ; } } if ( modify > 1 ) return false ; return true ; } static public void Main ( ) { int [ ] arr = { 10 , 5 , 11 , 3 } ; int n = arr . Length ; if ( check ( arr , n ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i, modify
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static int next_pos = 1 ; public class pair { public int first , second ; public pair ( ) { first = 0 ; second = 0 ; } } class sortHelper : IComparer { int IComparer . Compare ( object a , object b ) { pair first = ( pair ) a ; pair second = ( pair ) b ; return first . first < second . first ? - 1 : 1 ; } } static void printIndices ( int n , pair [ ] a ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( a [ i ] . second + " ▁ " ) ; Console . WriteLine ( ) ; } static void printPermutations ( int n , int [ ] a , int k ) { pair [ ] arr = new pair [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = new pair ( ) ; arr [ i ] . first = a [ i ] ; arr [ i ] . second = i ; } Array . Sort ( arr , new sortHelper ( ) ) ; int count = 1 ; for ( int i = 1 ; i < n ; i ++ ) if ( arr [ i ] . first == arr [ i - 1 ] . first ) count ++ ; if ( count < k ) { Console . Write ( " - 1" ) ; return ; } for ( int i = 0 ; i < k - 1 ; i ++ ) { printIndices ( n , arr ) ; for ( int j = next_pos ; j < n ; j ++ ) { if ( arr [ j ] . first == arr [ j - 1 ] . first ) { pair t = arr [ j ] ; arr [ j ] = arr [ j - 1 ] ; arr [ j - 1 ] = t ; next_pos = j + 1 ; break ; } } } printIndices ( n , arr ) ; } public static void Main ( string [ ] args ) { int [ ] a = { 1 , 3 , 3 , 1 } ; int n = a . Length ; int k = 3 ; printPermutations ( n , a , k ) ; } }

Index/key variables: i, j, n
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG, pair, sortHelper
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } public class BinaryTree { public Node root ; public virtual int getMaxWidth ( Node node ) { int maxWidth = 0 ; int width ; int h = height ( node ) ; int i ; for ( i = 1 ; i <= h ; i ++ ) { width = getWidth ( node , i ) ; if ( width > maxWidth ) { maxWidth = width ; } } return maxWidth ; } public virtual int getWidth ( Node node , int level ) { if ( node == null ) { return 0 ; } if ( level == 1 ) { return 1 ; } else if ( level > 1 ) { return getWidth ( node . left , level - 1 ) + getWidth ( node . right , level - 1 ) ; } return 0 ; } public virtual int height ( Node node ) { if ( node == null ) { return 0 ; } else { int lHeight = height ( node . left ) ; int rHeight = height ( node . right ) ; return ( lHeight > rHeight ) ? ( lHeight + 1 ) : ( rHeight + 1 ) ; } } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 5 ) ; tree . root . right . right = new Node ( 8 ) ; tree . root . right . right . left = new Node ( 6 ) ; tree . root . right . right . right = new Node ( 7 ) ; Console . WriteLine ( " Maximum ▁ width ▁ is ▁ " + tree . getMaxWidth ( tree . root ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: BinaryTree, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int countDistinct ( int [ ] arr , int n ) { HashSet < int > hs = new HashSet < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { hs . Add ( arr [ i ] ) ; } return hs . Count ; } public static void Main ( ) { int [ ] arr = new int [ ] { 6 , 10 , 5 , 4 , 9 , 120 , 4 , 6 , 10 } ; Console . WriteLine ( countDistinct ( arr , arr . Length ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int findOptimalSolution ( int [ ] a , int N ) { Array . Sort ( a ) ; int points = 0 ; for ( int i = 0 ; i < N ; i ++ ) { points += a [ i ] * i ; } return points ; } static public void Main ( ) { int [ ] a = { 1 , 4 , 2 , 3 , 9 } ; int N = a . Length ; Console . WriteLine ( findOptimalSolution ( a , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, points
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class Improve { static int number_of_tower ( int [ ] house , int range , int n ) { Array . Sort ( house ) ; int numOfTower = 0 ; int i = 0 ; while ( i < n ) { numOfTower ++ ; int loc = house [ i ] + range ; while ( i < n && house [ i ] <= loc ) i ++ ; -- i ; loc = house [ i ] + range ; while ( i < n && house [ i ] <= loc ) i ++ ; } return numOfTower ; } public static void Main ( ) { int [ ] house = { 7 , 2 , 4 , 6 , 5 , 9 , 12 , 11 } ; int range = 2 ; int n = house . Length ; Console . WriteLine ( number_of_tower ( house , range , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, numOfTower
Class/struct names: Improve
C# program:
using System ; public class GFG { static bool isAlphabaticOrder ( String s ) { int n = s . Length ; char [ ] c = new char [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { c [ i ] = s [ i ] ; } Array . Sort ( c ) ; for ( int i = 0 ; i < n ; i ++ ) if ( c [ i ] != s [ i ] ) return false ; return true ; } static public void Main ( ) { String s = " aabbbcc " ; if ( isAlphabaticOrder ( s ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

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