dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { public class Graph { int V ; List < int > [ ] adj ; public Graph ( int V ) { this . V = V ; this . adj = new List < int > [ V ] ; for ( int i = 0 ; i < V ; i ++ ) adj [ i ] = new List < int > ( ) ; } public void addEdge ( int u , int v ) { this . adj [ u ] . Add ( v ) ; this . adj [ v ] . Add ( u ) ; } bool DFSUtil ( int v , bool [ ] visited , int [ ] vDegree , int k ) { visited [ v ] = true ; foreach ( int i in adj [ v ] ) { if ( vDegree [ v ] < k ) vDegree [ i ] -- ; if ( ! visited [ i ] ) { DFSUtil ( i , visited , vDegree , k ) ; } } return ( vDegree [ v ] < k ) ; } public void printKCores ( int k ) { bool [ ] visited = new bool [ V ] ; bool [ ] processed = new bool [ V ] ; int mindeg = int . MaxValue ; int startvertex = 0 ; int [ ] vDegree = new int [ V ] ; for ( int i = 0 ; i < V ; i ++ ) { vDegree [ i ] = adj [ i ] . Count ; if ( vDegree [ i ] < mindeg ) { mindeg = vDegree [ i ] ; startvertex = i ; } } DFSUtil ( startvertex , visited , vDegree , k ) ; for ( int i = 0 ; i < V ; i ++ ) if ( ! visited [ i ] ) DFSUtil ( i , visited , vDegree , k ) ; Console . WriteLine ( " K - Cores ▁ : ▁ " ) ; for ( int v = 0 ; v < V ; v ++ ) { if ( vDegree [ v ] >= k ) { Console . Write ( " STRNEWLINE ▁ " + v ) ; foreach ( int i in adj [ v ] ) if ( vDegree [ i ] >= k ) Console . Write ( " ▁ - > ▁ " + i ) ; } } } } public static void Main ( String [ ] args ) { int k = 3 ; Graph g1 = new Graph ( 9 ) ; g1 . addEdge ( 0 , 1 ) ; g1 . addEdge ( 0 , 2 ) ; g1 . addEdge ( 1 , 2 ) ; g1 . addEdge ( 1 , 5 ) ; g1 . addEdge ( 2 , 3 ) ; g1 . addEdge ( 2 , 4 ) ; g1 . addEdge ( 2 , 5 ) ; g1 . addEdge ( 2 , 6 ) ; g1 . addEdge ( 3 , 4 ) ; g1 . addEdge ( 3 , 6 ) ; g1 . addEdge ( 3 , 7 ) ; g1 . addEdge ( 4 , 6 ) ; g1 . addEdge ( 4 , 7 ) ; g1 . addEdge ( 5 , 6 ) ; g1 . addEdge ( 5 , 8 ) ; g1 . addEdge ( 6 , 7 ) ; g1 . addEdge ( 6 , 8 ) ; g1 . printKCores ( k ) ; Console . WriteLine ( ) ; Graph g2 = new Graph ( 13 ) ; g2 . addEdge ( 0 , 1 ) ; g2 . addEdge ( 0 , 2 ) ; g2 . addEdge ( 0 , 3 ) ; g2 . addEdge ( 1 , 4 ) ; g2 . addEdge ( 1 , 5 ) ; g2 . addEdge ( 1 , 6 ) ; g2 . addEdge ( 2 , 7 ) ; g2 . addEdge ( 2 , 8 ) ; g2 . addEdge ( 2 , 9 ) ; g2 . addEdge ( 3 , 10 ) ; g2 . addEdge ( 3 , 11 ) ; g2 . addEdge ( 3 , 12 ) ; g2 . printKCores ( k ) ; } }

Index/key variables: V, i, u, v
Accumulator variables: i, v
Iterator variables: i, v
Class/struct names: GFG, Graph
C# program:
using System ; class GFG { public static int count = 0 ; public class Node { public int data ; public Node left ; public Node right ; } public static Node newNode ( int data ) { Node node = new Node ( ) ; node . data = data ; node . left = null ; node . right = null ; return ( node ) ; } public static void NthInorder ( Node node , int n ) { if ( node == null ) { return ; } if ( count <= n ) { NthInorder ( node . left , n ) ; count ++ ; if ( count == n ) { Console . Write ( " { 0 : D } ▁ " , node . data ) ; } NthInorder ( node . right , n ) ; } } public static void Main ( string [ ] args ) { Node root = newNode ( 10 ) ; root . left = newNode ( 20 ) ; root . right = newNode ( 30 ) ; root . left . left = newNode ( 40 ) ; root . left . right = newNode ( 50 ) ; int n = 4 ; NthInorder ( root , n ) ; } }

Accumulator variables: count
Class/struct names: GFG, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { static void printLevels ( List < List < int > > graph , int V , int x ) { int [ ] level = new int [ V ] ; Boolean [ ] marked = new Boolean [ V ] ; Queue < int > que = new Queue < int > ( ) ; que . Enqueue ( x ) ; level [ x ] = 0 ; marked [ x ] = true ; while ( que . Count > 0 ) { x = que . Peek ( ) ; que . Dequeue ( ) ; for ( int i = 0 ; i < graph [ x ] . Count ; i ++ ) { int b = graph [ x ] [ i ] ; if ( ! marked [ b ] ) { que . Enqueue ( b ) ; level [ b ] = level [ x ] + 1 ; marked [ b ] = true ; } } } Console . WriteLine ( " Nodes " + " ▁ " + " Level " ) ; for ( int i = 0 ; i < V ; i ++ ) Console . WriteLine ( " ▁ " + i + " ▁ - - > ▁ " + level [ i ] ) ; } public static void Main ( String [ ] args ) { int V = 8 ; List < List < int > > graph = new List < List < int > > ( ) ; for ( int i = 0 ; i < V + 1 ; i ++ ) graph . Add ( new List < int > ( ) ) ; graph [ 0 ] . Add ( 1 ) ; graph [ 0 ] . Add ( 2 ) ; graph [ 1 ] . Add ( 3 ) ; graph [ 1 ] . Add ( 4 ) ; graph [ 1 ] . Add ( 5 ) ; graph [ 2 ] . Add ( 5 ) ; graph [ 2 ] . Add ( 6 ) ; graph [ 6 ] . Add ( 7 ) ; printLevels ( graph , V , 0 ) ; } }

Index/key variables: V, b, i, x
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void dfs ( int parent , int [ ] ans , List < int > [ ] connectchars ) { ans [ parent ] = 1 ; for ( int i = 0 ; i < connectchars [ parent ] . Count ; i ++ ) { if ( ans [ connectchars [ parent ] [ i ] ] != 1 ) dfs ( connectchars [ parent ] [ i ] , ans , connectchars ) ; } } static void printBinaryPalindrome ( int n , int k ) { int [ ] arr = new int [ n ] ; int [ ] ans = new int [ n ] ; List < int > [ ] connectchars = new List < int > [ k ] ; for ( int i = 0 ; i < k ; i ++ ) connectchars [ i ] = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = i % k ; for ( int i = 0 ; i < n / 2 ; i ++ ) { connectchars [ arr [ i ] ] . Add ( arr [ n - i - 1 ] ) ; connectchars [ arr [ n - i - 1 ] ] . Add ( arr [ i ] ) ; } dfs ( 0 , ans , connectchars ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( ans [ arr [ i ] ] ) ; } public static void Main ( String [ ] args ) { int n = 10 , k = 4 ; printBinaryPalindrome ( n , k ) ; } }

Index/key variables: i, k, n, parent
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class NthNodePostOrder { public class Node { public int data ; public Node left , right ; public Node ( int data ) { this . data = data ; } } static int flag = 0 ; static void NthPostordernode ( Node root , int N ) { if ( root == null ) return ; if ( flag <= N ) { NthPostordernode ( root . left , N ) ; NthPostordernode ( root . right , N ) ; flag ++ ; if ( flag == N ) Console . Write ( root . data ) ; } } public static void Main ( String [ ] args ) { Node root = new Node ( 25 ) ; root . left = new Node ( 20 ) ; root . right = new Node ( 30 ) ; root . left . left = new Node ( 18 ) ; root . left . right = new Node ( 22 ) ; root . right . left = new Node ( 24 ) ; root . right . right = new Node ( 32 ) ; int N = 6 ; NthPostordernode ( root , N ) ; } }

Accumulator variables: flag
Class/struct names: Node, NthNodePostOrder
C# program:
using System ; using System . Collections . Generic ; public class GFG { public static void dfs ( List < int > [ ] list , int node , int arrival ) { Console . WriteLine ( node ) ; for ( int i = 0 ; i < list [ node ] . Count ; i ++ ) { if ( list [ node ] [ i ] != arrival ) dfs ( list , list [ node ] [ i ] , node ) ; } } public static void Main ( String [ ] args ) { int nodes = 5 ; List < int > [ ] list = new List < int > [ nodes + 1 ] ; for ( int i = 0 ; i < list . Length ; i ++ ) { list [ i ] = new List < int > ( ) ; } list [ 1 ] . Add ( 2 ) ; list [ 2 ] . Add ( 1 ) ; list [ 1 ] . Add ( 3 ) ; list [ 3 ] . Add ( 1 ) ; list [ 2 ] . Add ( 4 ) ; list [ 4 ] . Add ( 2 ) ; list [ 3 ] . Add ( 5 ) ; list [ 5 ] . Add ( 3 ) ; dfs ( list , 1 , 0 ) ; } }

Index/key variables: i, node
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static long [ ] count_color = new long [ 2 ] ; static void dfs ( List < int > [ ] adj , int node , int parent , bool color ) { count_color [ color == false ? 0 : 1 ] ++ ; for ( int i = 0 ; i < adj [ node ] . Count ; i ++ ) { if ( adj [ node ] [ i ] != parent ) dfs ( adj , adj [ node ] [ i ] , node , ! color ) ; } } static int findMaxEdges ( List < int > [ ] adj , int n ) { dfs ( adj , 1 , 0 , false ) ; return ( int ) ( count_color [ 0 ] * count_color [ 1 ] - ( n - 1 ) ) ; } public static void Main ( String [ ] args ) { int n = 5 ; List < int > [ ] adj = new List < int > [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) adj [ i ] = new List < int > ( ) ; adj [ 1 ] . Add ( 2 ) ; adj [ 1 ] . Add ( 3 ) ; adj [ 2 ] . Add ( 4 ) ; adj [ 3 ] . Add ( 5 ) ; Console . WriteLine ( findMaxEdges ( adj , n ) ) ; } }

Index/key variables: i, node
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countMinSteps ( int [ ] arr , int target , int n ) { Array . Sort ( arr ) ; int minimumSteps = 0 ; int i = 0 ; int j = n - 1 ; while ( i <= j ) { if ( arr [ i ] + arr [ j ] <= target ) { i += 1 ; j -= 1 ; } else { j -= 1 ; } minimumSteps += 1 ; } return minimumSteps ; } public static void Main ( ) { int [ ] arr = new int [ ] { 4 , 6 , 2 , 9 , 6 , 5 , 8 , 10 } ; int target = 11 ; int size = arr . Length ; Console . Write ( countMinSteps ( arr , target , size ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, minimumSteps
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { public class interval { public int l , r , v ; } public class sortHelper : IComparer < interval > { public int Compare ( interval a , interval b ) { return ( a . v < b . v ? 1 : 0 ) ; } } static int MAX = 100001 ; static bool isPossible ( int [ , ] range , int N ) { interval [ ] test = new interval [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { test [ i ] = new interval ( ) ; test [ i ] . l = range [ i , 0 ] ; test [ i ] . r = range [ i , 1 ] ; test [ i ] . v = range [ i , 2 ] ; } Array . Sort ( test , new sortHelper ( ) ) ; for ( int i = 0 ; i < N ; i ++ ) { int [ ] count = new int [ MAX ] ; int current_velocity = test [ i ] . v ; int j = i ; while ( j < N && test [ j ] . v == current_velocity ) { for ( int k = test [ j ] . l ; k <= test [ j ] . r ; k ++ ) { count [ k ] ++ ; if ( count [ k ] >= 3 ) return false ; } j ++ ; } i = j - 1 ; } return true ; } public static void Main ( string [ ] args ) { int [ , ] range = { { 1 , 2 , 3 } , { 2 , 5 , 1 } , { 3 , 10 , 1 } , { 4 , 4 , 1 } , { 5 , 7 , 10 } } ; int n = range . GetLength ( 0 ) ; if ( isPossible ( range , n ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: MAX, N, i, j, k
Accumulator variables: i, j, k
Iterator variables: i, k
Class/struct names: GFG, interval, sortHelper
C# program:
using System ; using System . Collections . Generic ; class GFG { static int N = 2005 ; static HashSet < int > ans = new HashSet < int > ( ) ; static void dfs ( int num , int left , int ct ) { if ( ct >= 15 ) return ; if ( left == 0 ) ans . Add ( num ) ; for ( int i = 0 ; i <= Math . Min ( left , 9 ) ; i ++ ) dfs ( num * 10 + i , left - i , ct + 1 ) ; } static int getKthNum ( int m , int k ) { dfs ( 0 , m , 0 ) ; int ct = 0 ; foreach ( int it in ans ) { ct ++ ; if ( ct == k ) { return it ; } } return - 1 ; } public static void Main ( String [ ] args ) { int m = 5 , k = 3 ; Console . WriteLine ( getKthNum ( m , k ) ) ; } }

Accumulator variables: ct, i
Iterator variables: i, it
Class/struct names: GFG
C# program:
using System ; class GFG { public static int upperBound ( int [ ] array , int value ) { int low = 0 ; int high = array . Length ; while ( low < high ) { int mid = ( low + high ) / 2 ; if ( value >= array [ mid ] ) { low = mid + 1 ; } else { high = mid ; } } return low ; } public static int Removal ( int [ ] v , int n ) { Array . Sort ( v ) ; int ans = int . MaxValue ; int k = 0 ; foreach ( int i in v ) { int j = upperBound ( v , ( 2 * i ) ) ; ans = Math . Min ( ans , n - ( j - k ) ) ; k ++ ; } return ans ; } public static void Main ( String [ ] args ) { int [ ] a = { 4 , 5 , 100 , 9 , 10 , 11 , 12 , 15 , 200 } ; int n = a . Length ; Console . WriteLine ( Removal ( a , n ) ) ; } }

Index/key variables: mid
Accumulator variables: k
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void FrontToLast ( Queue < int > q , int qsize ) { if ( qsize <= 0 ) return ; q . Enqueue ( q . Peek ( ) ) ; q . Dequeue ( ) ; FrontToLast ( q , qsize - 1 ) ; } static void pushInQueue ( Queue < int > q , int temp , int qsize ) { if ( q . Count == 0 qsize == 0 ) { q . Enqueue ( temp ) ; return ; } else if ( temp <= q . Peek ( ) ) { q . Enqueue ( temp ) ; FrontToLast ( q , qsize ) ; } else { q . Enqueue ( q . Peek ( ) ) ; q . Dequeue ( ) ; pushInQueue ( q , temp , qsize - 1 ) ; } } static void sortQueue ( Queue < int > q ) { if ( q . Count == 0 ) return ; int temp = q . Peek ( ) ; q . Dequeue ( ) ; sortQueue ( q ) ; pushInQueue ( q , temp , q . Count ) ; } public static void Main ( String [ ] args ) { Queue < int > qu = new Queue < int > ( ) ; qu . Enqueue ( 10 ) ; qu . Enqueue ( 7 ) ; qu . Enqueue ( 16 ) ; qu . Enqueue ( 9 ) ; qu . Enqueue ( 20 ) ; qu . Enqueue ( 5 ) ; sortQueue ( qu ) ; while ( qu . Count != 0 ) { Console . Write ( qu . Peek ( ) + " ▁ " ) ; qu . Dequeue ( ) ; } } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int partition ( char [ ] arr , int low , int high , int mod ) { char pivot = arr [ high ] ; int i = ( low - 1 ) ; char t ; int piv = pivot % mod ; for ( int j = low ; j <= high - 1 ; j ++ ) { int a = arr [ j ] % mod ; if ( a <= piv ) { i ++ ; t = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = t ; } } t = arr [ i + 1 ] ; arr [ i + 1 ] = arr [ high ] ; arr [ high ] = t ; return ( i + 1 ) ; } static void quickSort ( char [ ] arr , int low , int high , int mod ) { if ( low < high ) { int pi = partition ( arr , low , high , mod ) ; quickSort ( arr , low , pi - 1 , mod ) ; quickSort ( arr , pi + 1 , high , mod ) ; } } static void printArray ( char [ ] arr , int size ) { for ( int i = 0 ; i < size ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } public static void Main ( ) { char [ ] arr = { ' g ' , ' e ' , ' e ' , ' k ' , ' s ' } ; int n = arr . Length ; int mod = 8 ; quickSort ( arr , 0 , n - 1 , mod ) ; printArray ( arr , n ) ; } }

Index/key variables: high, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public class Node { public int data ; public Node next ; } ; static Node newNode ( int val ) { Node temp = new Node ( ) ; temp . data = val ; temp . next = null ; return temp ; } static Node selectionSort ( Node head ) { Node a , b , c , d , r ; a = b = head ; while ( b . next != null ) { c = d = b . next ; while ( d != null ) { if ( b . data > d . data ) { if ( b . next == d ) { if ( b == head ) { b . next = d . next ; d . next = b ; r = b ; b = d ; d = r ; c = d ; head = b ; d = d . next ; } else { b . next = d . next ; d . next = b ; a . next = d ; r = b ; b = d ; d = r ; c = d ; d = d . next ; } } else { if ( b == head ) { r = b . next ; b . next = d . next ; d . next = r ; c . next = b ; r = b ; b = d ; d = r ; c = d ; d = d . next ; head = b ; } else { r = b . next ; b . next = d . next ; d . next = r ; c . next = b ; a . next = d ; r = b ; b = d ; d = r ; c = d ; d = d . next ; } } } else { c = d ; d = d . next ; } } a = b ; b = b . next ; } return head ; } static void printList ( Node head ) { while ( head != null ) { Console . Write ( head . data + " ▁ " ) ; head = head . next ; } } public static void Main ( String [ ] arg ) { Node head = newNode ( 5 ) ; head . next = newNode ( 4 ) ; head . next . next = newNode ( 3 ) ; head = selectionSort ( head ) ; printList ( head ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; class GFG { static void printArr ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } static void findNumbers ( int [ ] arr , int n ) { Array . Sort ( arr ) ; reverse ( arr ) ; int [ ] freq = new int [ arr [ 0 ] + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { freq [ arr [ i ] ] ++ ; } int size = ( int ) Math . Sqrt ( n ) ; int [ ] brr = new int [ size ] ; int x , l = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( freq [ arr [ i ] ] > 0 && l < size ) { brr [ l ] = arr [ i ] ; freq [ brr [ l ] ] -- ; l ++ ; for ( int j = 0 ; j < l ; j ++ ) { if ( i != j ) { x = __gcd ( arr [ i ] , brr [ j ] ) ; freq [ x ] -= 2 ; } } } } printArr ( brr , size ) ; } public static void reverse ( int [ ] input ) { int last = input . Length - 1 ; int middle = input . Length / 2 ; for ( int i = 0 ; i <= middle ; i ++ ) { int temp = input [ i ] ; input [ i ] = input [ last - i ] ; input [ last - i ] = temp ; } } static int __gcd ( int a , int b ) { if ( b == 0 ) { return a ; } return __gcd ( b , a % b ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 5 , 5 , 5 , 7 , 10 , 12 , 2 , 2 } ; int n = arr . Length ; findNumbers ( arr , n ) ; } }

Index/key variables: i, j, l, size, x
Accumulator variables: i, j, l
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GfG { static String strBitwiseAND ( String [ ] arr , int n ) { String res = " " ; int smallest_size = int . MaxValue ; int largest_size = int . MinValue ; String temp = " " ; for ( int i = 0 ; i < n ; i ++ ) { temp += arr [ i ] ; arr [ i ] = reverse ( temp ) ; smallest_size = Math . Min ( smallest_size , arr [ i ] . Length ) ; largest_size = Math . Max ( largest_size , arr [ i ] . Length ) ; } for ( int i = 0 ; i < smallest_size ; i ++ ) { bool all_ones = true ; for ( int j = 0 ; j < n ; j ++ ) { if ( arr [ j ] [ i ] == '0' ) { all_ones = false ; break ; } } res += ( all_ones ? '1' : '0' ) ; } for ( int i = 0 ; i < largest_size - smallest_size ; i ++ ) res += '0' ; String temp1 = " " ; temp1 += res ; res = reverse ( temp1 ) ; return res ; } static String reverse ( String input ) { char [ ] temparray = input . ToCharArray ( ) ; int left , right = 0 ; right = temparray . Length - 1 ; for ( left = 0 ; left < right ; left ++ , right -- ) { char temp = temparray [ left ] ; temparray [ left ] = temparray [ right ] ; temparray [ right ] = temp ; } return String . Join ( " " , temparray ) ; } public static void Main ( String [ ] args ) { String [ ] arr = { "101" , "110110" , "111" } ; int n = arr . Length ; Console . WriteLine ( strBitwiseAND ( arr , n ) ) ; } }

Index/key variables: i, j, left, right
Accumulator variables: i, j, left, res, right, temp, temp1
Iterator variables: i, j, left
Boolean variables: all_ones
Class/struct names: GfG
C# program:
using System ; using System . Collections ; class GFG { static void AlternateRearrange ( int [ ] arr , int n ) { Array . Sort ( arr ) ; for ( int j = 0 ; j < n ; j ++ ) if ( arr [ j ] % 2 == 0 ) v1 . Add ( arr [ j ] ) ; else v2 . Add ( arr [ j ] ) ; int index = 0 , i = 0 , k = 0 ; bool flag = false ; if ( arr [ 0 ] % 2 == 0 ) flag = true ; while ( index < n ) { if ( flag == true ) { arr [ index ] = ( int ) v1 [ i ] ; i += 1 ; index += 1 ; flag = ! flag ; } else { arr [ index ] = ( int ) v2 [ k ] ; k += 1 ; index += 1 ; flag = ! flag ; } } for ( i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } static void Main ( ) { int [ ] arr = { 9 , 8 , 13 , 2 , 19 , 14 } ; int n = arr . Length ; AlternateRearrange ( arr , n ) ; } }

Index/key variables: i, index, j, k
Accumulator variables: i, index, j, k
Iterator variables: i, j
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; public class GFG { static int getNumToAdd ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int d = arr [ 1 ] - arr [ 0 ] ; int numToAdd = - 1 ; bool numAdded = false ; for ( int i = 2 ; i < n ; i ++ ) { int diff = arr [ i ] - arr [ i - 1 ] ; if ( diff != d ) { if ( numAdded ) return - 1 ; if ( diff == 2 * d ) { numToAdd = arr [ i ] - d ; numAdded = true ; } else return - 1 ; } } if ( numToAdd == - 1 ) return ( arr [ n - 1 ] + d ) ; return numToAdd ; } public static void Main ( ) { int [ ] arr = { 1 , 3 , 5 , 7 , 11 , 13 , 15 } ; int n = arr . Length ; Console . WriteLine ( getNumToAdd ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: numAdded
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int Minimum_Cells ( List < Tuple < int , int > > v ) { int [ ] col = new int [ 3 ] ; int i , j ; for ( i = 0 ; i < 3 ; i ++ ) { int column_number = v [ i ] . Item2 ; col [ i ] = column_number ; } Array . Sort ( col ) ; v . Sort ( ) ; int MidRow = v [ 1 ] . Item1 ; HashSet < Tuple < int , int > > s = new HashSet < Tuple < int , int > > ( ) ; int Maxcol = col [ 2 ] , MinCol = col [ 0 ] ; for ( i = MinCol ; i <= Maxcol ; i ++ ) { s . Add ( new Tuple < int , int > ( MidRow , i ) ) ; } for ( i = 0 ; i < 3 ; i ++ ) { if ( v [ i ] . Item1 == MidRow ) continue ; for ( j = Math . Min ( v [ i ] . Item1 , MidRow ) ; j <= Math . Max ( v [ i ] . Item1 , MidRow ) ; j ++ ) { s . Add ( new Tuple < int , int > ( j , v [ i ] . Item1 ) ) ; } } return s . Count ; } static void Main ( ) { List < Tuple < int , int > > v = new List < Tuple < int , int > > ( ) ; v . Add ( new Tuple < int , int > ( 0 , 0 ) ) ; v . Add ( new Tuple < int , int > ( 1 , 1 ) ) ; v . Add ( new Tuple < int , int > ( 2 , 2 ) ) ; Console . Write ( Minimum_Cells ( v ) ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int items ( int n , int [ ] a ) { Array . Sort ( a ) ; int z = a [ n - 1 ] ; int x = 1 ; int s = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { s += a [ i ] ; if ( s <= z ) x += 1 ; else break ; } return x ; } static public void Main ( ) { int n = 5 ; int [ ] a = { 5 , 3 , 1 , 5 , 6 } ; Console . WriteLine ( items ( n , a ) ) ; } }

Index/key variables: i
Accumulator variables: i, s, x
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class Node { static void sortWithSetbits ( int [ ] arr , int n , int k ) { List < int > v1 = new List < int > ( ) ; List < int > v2 = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( bitCount ( arr [ i ] ) == k ) { v1 . Add ( i ) ; v2 . Add ( arr [ i ] ) ; } } v2 . Sort ( ) ; for ( int i = 0 ; i < v1 . Count ; i ++ ) { arr [ v1 [ i ] ] = v2 [ i ] ; } for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } static int bitCount ( long x ) { int setBits = 0 ; while ( x != 0 ) { x = x & ( x - 1 ) ; setBits ++ ; } return setBits ; } public static void Main ( String [ ] args ) { int [ ] arr = { 14 , 255 , 1 , 7 , 13 } ; int n = arr . Length ; int k = 3 ; sortWithSetbits ( arr , n , k ) ; } }

Index/key variables: i
Accumulator variables: i, setBits
Iterator variables: i
Class/struct names: Node
C# program:
using System ; class GFG { static int numBoxes ( int [ ] A , int n , int K ) { Array . Sort ( A ) ; int i = 0 , j = ( n - 1 ) ; int ans = 0 ; while ( i <= j ) { ans ++ ; if ( A [ i ] + A [ j ] <= K ) i ++ ; j -- ; } return ans ; } static public void Main ( ) { int [ ] A = { 3 , 2 , 2 , 1 } ; int K = 3 ; int n = A . Length ; Console . WriteLine ( numBoxes ( A , n , K ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j
Class/struct names: GFG