dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static void findTwoMissingNumbers ( int [ ] arr , int n ) { int XOR = arr [ 0 ] ; for ( int i = 1 ; i < n - 2 ; i ++ ) XOR ^= arr [ i ] ; for ( int i = 1 ; i <= n ; i ++ ) XOR ^= i ; int set_bit_no = XOR & ~ ( XOR - 1 ) ; int x = 0 , y = 0 ; for ( int i = 0 ; i < n - 2 ; i ++ ) { if ( ( arr [ i ] & set_bit_no ) > 0 ) x = x ^ arr [ i ] ; else y = y ^ arr [ i ] ; } for ( int i = 1 ; i <= n ; i ++ ) { if ( ( i & set_bit_no ) > 0 ) x = x ^ i ; else y = y ^ i ; } Console . WriteLine ( " Two ▁ Missing ▁ Numbers ▁ are ▁ " ) ; Console . WriteLine ( x + " ▁ " + y ) ; } public static void Main ( ) { int [ ] arr = { 1 , 3 , 5 , 6 } ; int n = 2 + arr . Length ; findTwoMissingNumbers ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: XOR, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { public static int countSetBits ( int n ) { int count = 0 ; while ( n != 0 ) { n &= ( n - 1 ) ; count ++ ; } return count ; } public static char findProffesion ( int level , int pos ) { int c = countSetBits ( pos - 1 ) ; return ( c % 2 != 0 ) ? ' d ' : ' e ' ; } public static void Main ( string [ ] args ) { int level = 3 , pos = 4 ; string prof = ( findProffesion ( level , pos ) == ' e ' ) ? " Engineer " : " Doctor " ; Console . Write ( prof ) ; } }

Accumulator variables: count, n
Class/struct names: GFG
C# program:
using System ; class GFG { static int myXOR ( int x , int y ) { return ( x & ( ~ y ) ) | ( ( ~ x ) & y ) ; } public static void Main ( ) { int x = 3 , y = 5 ; Console . WriteLine ( " XOR ▁ is ▁ " + myXOR ( x , y ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int Max_Xor ( int [ ] arr , int n , int k ) { int maxXor = int . MinValue ; for ( int i = 0 ; i < ( 1 << n ) ; i ++ ) { if ( bitCount ( i ) == k ) { int cur_xor = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( i & ( 1 << j ) ) == 0 ) cur_xor = cur_xor ^ arr [ j ] ; } maxXor = Math . Max ( maxXor , cur_xor ) ; } } return maxXor ; } 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 = { 2 , 5 , 4 , 1 , 3 , 7 , 6 , 8 } ; int n = arr . Length ; int k = 3 ; Console . WriteLine ( Max_Xor ( arr , n , k ) ) ; } }

Index/key variables: j
Accumulator variables: i, j, setBits
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static double temp_convert ( int F1 , int B1 , int F2 , int B2 , int T ) { float t2 ; t2 = F2 + ( float ) ( B2 - F2 ) / ( B1 - F1 ) * ( T - F1 ) ; return t2 ; } public static void Main ( ) { int F1 = 0 , B1 = 100 ; int F2 = 32 , B2 = 212 ; int T = 37 ; Console . Write ( String . Format ( " { 0:0 . # # } " , temp_convert ( F1 , B1 , F2 , B2 , T ) ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int Divisible ( int [ ] arr , int n ) { int count_even = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] % 2 == 0 ) count_even ++ ; return count_even + ( n - count_even ) / 2 ; } static public void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; int n = arr . Length ; Console . Write ( Divisible ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: count_even, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { class Node { public int data ; public int children ; public Node left , right ; } static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . data = data ; temp . left = temp . right = null ; temp . children = 0 ; return temp ; } static int getElements ( Node root ) { if ( root == null ) return 0 ; return getElements ( root . left ) + getElements ( root . right ) + 1 ; } static Node insertChildrenCount ( Node root ) { if ( root == null ) return null ; root . children = getElements ( root ) - 1 ; root . left = insertChildrenCount ( root . left ) ; root . right = insertChildrenCount ( root . right ) ; return root ; } static int children ( Node root ) { if ( root == null ) return 0 ; return root . children + 1 ; } static int randomNodeUtil ( Node root , int count ) { if ( root == null ) return 0 ; if ( count == children ( root . left ) ) return root . data ; if ( count < children ( root . left ) ) return randomNodeUtil ( root . left , count ) ; return randomNodeUtil ( root . right , count - children ( root . left ) - 1 ) ; } static int randomNode ( Node root ) { int count = ( int ) new Random ( ) . Next ( 0 , root . children + 1 ) ; return randomNodeUtil ( root , count ) ; } public static void Main ( String [ ] args ) { Node root = newNode ( 10 ) ; root . left = newNode ( 20 ) ; root . right = newNode ( 30 ) ; root . left . right = newNode ( 40 ) ; root . left . right = newNode ( 50 ) ; root . right . left = newNode ( 60 ) ; root . right . right = newNode ( 70 ) ; insertChildrenCount ( root ) ; Console . Write ( " A ▁ Random ▁ Node ▁ From ▁ Tree ▁ : ▁ " + randomNode ( root ) ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; class GFG { static int rand2 ( ) { Random rand = new Random ( ) ; return ( rand . Next ( ) & 1 ) ; } static int rand3 ( ) { int r = 2 * rand2 ( ) + rand2 ( ) ; if ( r < 3 ) return r ; return rand3 ( ) ; } static void Main ( ) { for ( int i = 0 ; i < 100 ; i ++ ) Console . Write ( rand3 ( ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GfG { class Node { public int data ; public Node left , right ; } static Node newNode ( int data ) { Node newNode = new Node ( ) ; newNode . data = data ; newNode . left = null ; newNode . right = null ; return ( newNode ) ; } static Node deleteLeaves ( Node root , int x ) { if ( root == null ) return null ; root . left = deleteLeaves ( root . left , x ) ; root . right = deleteLeaves ( root . right , x ) ; if ( root . data == x && root . left == null && root . right == null ) { return null ; } return root ; } static void inorder ( Node root ) { if ( root == null ) return ; inorder ( root . left ) ; Console . Write ( root . data + " ▁ " ) ; inorder ( root . right ) ; } public static void Main ( String [ ] args ) { Node root = newNode ( 10 ) ; root . left = newNode ( 3 ) ; root . right = newNode ( 10 ) ; root . left . left = newNode ( 3 ) ; root . left . right = newNode ( 1 ) ; root . right . right = newNode ( 3 ) ; root . right . right . left = newNode ( 3 ) ; root . right . right . right = newNode ( 3 ) ; deleteLeaves ( root , 3 ) ; Console . Write ( " Inorder ▁ traversal ▁ after ▁ deletion ▁ : ▁ " ) ; inorder ( root ) ; } }

Class/struct names: GfG, Node
C# program:
using System ; using System . Collections . Generic ; public class Node { public int data ; public Node left , right ; public Node ( int data ) { this . data = data ; left = right = null ; } } public class BinaryTree { Node root ; void _deleteTree ( ) { if ( root == null ) return ; Queue < Node > q = new Queue < Node > ( ) ; q . Enqueue ( root ) ; while ( q . Count != 0 ) { Node node = q . Peek ( ) ; q . Dequeue ( ) ; if ( node . left != null ) q . Enqueue ( node . left ) ; if ( node . right != null ) q . Enqueue ( node . right ) ; } } void deleteTree ( ) { _deleteTree ( ) ; root = null ; } public static void Main ( String [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 15 ) ; tree . root . left = new Node ( 10 ) ; tree . root . right = new Node ( 20 ) ; tree . root . left . left = new Node ( 8 ) ; tree . root . left . right = new Node ( 12 ) ; tree . root . right . left = new Node ( 16 ) ; tree . root . right . right = new Node ( 25 ) ; tree . deleteTree ( ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; using System . Collections . Generic ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } public class BinaryTree { Node root ; public int size ( ) { if ( root == null ) return 0 ; Queue < Node > q = new Queue < Node > ( ) ; q . Enqueue ( root ) ; int count = 1 ; while ( q . Count != 0 ) { Node tmp = q . Dequeue ( ) ; if ( tmp != null ) { if ( tmp . left != null ) { count ++ ; q . Enqueue ( tmp . left ) ; } if ( tmp . right != null ) { count ++ ; q . Enqueue ( tmp . right ) ; } } } return count ; } 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 ▁ size ▁ of ▁ binary ▁ tree " + " ▁ is ▁ : ▁ " + tree . size ( ) ) ; } }

Accumulator variables: count
Class/struct names: BinaryTree, Node
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 { Node root ; int maxDepth ( Node node ) { if ( node == null ) return 0 ; else { int lDepth = maxDepth ( node . left ) ; int rDepth = maxDepth ( node . right ) ; if ( lDepth > rDepth ) return ( lDepth + 1 ) ; else return ( rDepth + 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 ( " Height ▁ of ▁ tree ▁ is ▁ : ▁ " + tree . maxDepth ( tree . root ) ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; class GFG { public class INT { public int data ; public INT ( int d ) { data = d ; } } public static void findPostOrderUtil ( int [ ] pre , int n , int minval , int maxval , INT preIndex ) { if ( preIndex . data == n ) { return ; } if ( pre [ preIndex . data ] < minval pre [ preIndex . data ] > maxval ) { return ; } int val = pre [ preIndex . data ] ; preIndex . data ++ ; findPostOrderUtil ( pre , n , minval , val , preIndex ) ; findPostOrderUtil ( pre , n , val , maxval , preIndex ) ; Console . Write ( val + " ▁ " ) ; } public static void findPostOrder ( int [ ] pre , int n ) { INT preIndex = new INT ( 0 ) ; findPostOrderUtil ( pre , n , int . MinValue , int . MaxValue , preIndex ) ; } public static void Main ( string [ ] args ) { int [ ] pre = new int [ ] { 40 , 30 , 35 , 80 , 100 } ; int n = pre . Length ; findPostOrder ( pre , n ) ; } }

Accumulator variables: data
Class/struct names: GFG, INT
C# program:
using System ; class GfG { class Node { public int data ; public Node left ; public Node right ; } static int heightOfTreeUtil ( Node root , bool isEven ) { if ( root == null ) return 0 ; if ( root . left == null && root . right == null ) { if ( isEven == true ) return 1 ; else return 0 ; } int left = heightOfTreeUtil ( root . left , ! isEven ) ; int right = heightOfTreeUtil ( root . right , ! isEven ) ; if ( left == 0 && right == 0 ) return 0 ; return ( 1 + Math . Max ( left , right ) ) ; } static Node newNode ( int data ) { Node node = new Node ( ) ; node . data = data ; node . left = null ; node . right = null ; return ( node ) ; } static int heightOfTree ( Node root ) { return heightOfTreeUtil ( root , false ) ; } 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 ) ; root . left . right . left = newNode ( 6 ) ; Console . WriteLine ( " Height ▁ of ▁ tree ▁ is ▁ " + heightOfTree ( root ) ) ; } }

Class/struct names: GfG, Node
C# program:
using System ; public class BinaryTree { public virtual void fillDepth ( int [ ] parent , int i , int [ ] depth ) { if ( depth [ i ] != 0 ) { return ; } if ( parent [ i ] == - 1 ) { depth [ i ] = 1 ; return ; } if ( depth [ parent [ i ] ] == 0 ) { fillDepth ( parent , parent [ i ] , depth ) ; } depth [ i ] = depth [ parent [ i ] ] + 1 ; } public virtual int findHeight ( int [ ] parent , int n ) { int [ ] depth = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { depth [ i ] = 0 ; } for ( int i = 0 ; i < n ; i ++ ) { fillDepth ( parent , i , depth ) ; } int ht = depth [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( ht < depth [ i ] ) { ht = depth [ i ] ; } } return ht ; } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; int [ ] parent = new int [ ] { - 1 , 0 , 0 , 1 , 1 , 3 , 5 } ; int n = parent . Length ; Console . WriteLine ( " Height ▁ is ▁ " + tree . findHeight ( parent , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: BinaryTree
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int d ) { data = d ; left = right = null ; } } public class BinaryTree { public Node root ; public virtual bool isBalanced ( Node node ) { int lh ; int rh ; if ( node == null ) { return true ; } lh = height ( node . left ) ; rh = height ( node . right ) ; if ( Math . Abs ( lh - rh ) <= 1 && isBalanced ( node . left ) && isBalanced ( node . right ) ) { return true ; } return false ; } public virtual int height ( Node node ) { if ( node == null ) { return 0 ; } return 1 + Math . Max ( height ( node . left ) , height ( node . right ) ) ; } 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 . left . left . left = new Node ( 8 ) ; if ( tree . isBalanced ( tree . root ) ) { Console . WriteLine ( " Tree ▁ is ▁ balanced " ) ; } else { Console . WriteLine ( " Tree ▁ is ▁ not ▁ balanced " ) ; } } }

Class/struct names: BinaryTree, Node
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int key ) { data = key ; left = right = null ; } } public class GFG { static bool isLeaf ( Node node ) { return ( node . left != null && node . left . right == node && node . right != null && node . right . left == node ) ; } static int maxDepth ( Node node ) { if ( node == null ) return 0 ; if ( isLeaf ( node ) ) return 1 ; return 1 + Math . Max ( maxDepth ( node . left ) , maxDepth ( node . right ) ) ; } public static void Main ( String [ ] args ) { Node root = new Node ( 1 ) ; root . left = new Node ( 2 ) ; root . right = new Node ( 3 ) ; root . left . left = new Node ( 4 ) ; root . left . right = new Node ( 5 ) ; root . left . left . left = new Node ( 6 ) ; Node L1 = root . left . left . left ; Node L2 = root . left . right ; Node L3 = root . right ; L1 . right = L2 ; L2 . right = L3 ; L3 . right = L1 ; L3 . left = L2 ; L2 . left = L1 ; L1 . left = L3 ; Console . WriteLine ( " Height ▁ of ▁ tree ▁ is ▁ " + maxDepth ( root ) ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; namespace Tree { class Tree < T > { public Tree ( T value ) { this . value = value ; } public T value { get ; set ; } public Tree < T > left { get ; set ; } public Tree < T > right { get ; set ; } } public class TreeDiameter { Tree < int > root ; int Height ( Tree < int > node ) { if ( node == null ) return 0 ; return 1 + Math . Max ( Height ( node . left ) , Height ( node . right ) ) ; } int Diameter ( Tree < int > root ) { if ( root == null ) return 0 ; int lHeight = Height ( root . left ) ; int rHeight = Height ( root . right ) ; int lDiameter = Diameter ( root . left ) ; int rDiameter = Diameter ( root . right ) ; return Math . Max ( lHeight + rHeight + 1 , Math . Max ( lDiameter , rDiameter ) ) ; } int Diameter ( ) { return Diameter ( root ) ; } public static void Main ( string [ ] args ) { TreeDiameter tree = new TreeDiameter ( ) ; tree . root = new Tree < int > ( 1 ) ; tree . root . left = new Tree < int > ( 2 ) ; tree . root . right = new Tree < int > ( 3 ) ; tree . root . left . left = new Tree < int > ( 4 ) ; tree . root . left . right = new Tree < int > ( 5 ) ; Console . WriteLine ( $" The diameter of given binary tree is :  { tree . Diameter ( ) } " ) ; } } }

Class/struct names: Tree, TreeDiameter
C# program:
using System ; class GFG { static void findpath ( int N , int [ ] a ) { if ( a [ 0 ] != 0 ) { Console . Write ( N + 1 ) ; for ( int i = 1 ; i <= N ; i ++ ) Console . Write ( i + " ▁ " ) ; return ; } for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( a [ i ] == 0 && a [ i + 1 ] != 0 ) { for ( int j = 1 ; j <= i ; j ++ ) Console . Write ( j + " ▁ " ) ; Console . Write ( N + 1 + " ▁ " ) ; for ( int j = i + 1 ; j <= N ; j ++ ) Console . Write ( j + " ▁ " ) ; return ; } } for ( int i = 1 ; i <= N ; i ++ ) Console . Write ( i + " ▁ " ) ; Console . Write ( N + 1 + " ▁ " ) ; } public static void Main ( ) { int N = 3 ; int [ ] arr = { 0 , 1 , 0 } ; findpath ( N , arr ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void balBracketSequence ( string str ) { int n = str . Length ; if ( str [ 0 ] == str [ n - 1 ] ) { Console . Write ( " No " ) ; } else { int cntForOpen = 0 , cntForClose = 0 ; int check = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == str [ 0 ] ) cntForOpen ++ ; else if ( str [ i ] == str [ n - 1 ] ) cntForOpen -- ; else cntForOpen ++ ; if ( cntForOpen < 0 ) { check = 0 ; break ; } } if ( check != 0 && cntForOpen == 0 ) { Console . Write ( " Yes , ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == str [ n - 1 ] ) Console . Write ( ' ) ' ) ; else Console . Write ( ' ( ' ) ; } return ; } else { for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == str [ 0 ] ) cntForClose ++ ; else cntForClose -- ; if ( cntForClose < 0 ) { check = 0 ; break ; } } if ( check != 0 && cntForClose == 0 ) { Console . Write ( " Yes , ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == str [ 0 ] ) Console . Write ( ' ( ' ) ; else Console . Write ( ' ) ' ) ; } return ; } } Console . Write ( " No " ) ; } } public static void Main ( ) { string str = "123122" ; balBracketSequence ( str ) ; } }

Index/key variables: i
Accumulator variables: cntForClose, cntForOpen, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } class Height { public int h ; } class BinaryTree { public Node root ; public int diameterOpt ( Node root , Height height ) { Height lh = new Height ( ) , rh = new Height ( ) ; if ( root == null ) { height . h = 0 ; return 0 ; } int ldiameter = diameterOpt ( root . left , lh ) ; int rdiameter = diameterOpt ( root . right , rh ) ; height . h = Math . Max ( lh . h , rh . h ) + 1 ; return Math . Max ( lh . h + rh . h + 1 , Math . Max ( ldiameter , rdiameter ) ) ; } public int diameter ( ) { Height height = new Height ( ) ; return diameterOpt ( root , height ) ; } public int height ( Node node ) { if ( node == null ) return 0 ; return ( 1 + Math . Max ( height ( node . left ) , height ( node . right ) ) ) ; } static void Main ( ) { 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 . Write ( " The ▁ diameter ▁ of ▁ given ▁ binary ▁ tree ▁ is ▁ : ▁ " + tree . diameter ( ) ) ; } }

Class/struct names: BinaryTree, Height, Node
C# program:
using System ; class GfG { class Node { public int data ; public Node left , right ; } class A { public int ans = int . MinValue ; } static int height ( Node root , A a ) { if ( root == null ) return 0 ; int left_height = height ( root . left , a ) ; int right_height = height ( root . right , a ) ; a . ans = Math . Max ( a . ans , 1 + left_height + right_height ) ; return 1 + Math . Max ( left_height , right_height ) ; } static int diameter ( Node root ) { if ( root == null ) return 0 ; A a = new A ( ) ; int height_of_tree = height ( root , a ) ; return a . ans ; } static Node newNode ( int data ) { Node node = new Node ( ) ; node . data = data ; node . left = null ; node . right = null ; return ( node ) ; } public static void Main ( ) { Node root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 3 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 5 ) ; Console . WriteLine ( " Diameter ▁ is ▁ " + diameter ( root ) ) ; } }

Class/struct names: A, GfG, Node
C# program:
using System ; class GFG { public void getPostOrderBST ( int [ ] pre ) { int pivotPoint = 0 ; for ( int i = 1 ; i < pre . Length ; i ++ ) { if ( pre [ 0 ] <= pre [ i ] ) { pivotPoint = i ; break ; } } for ( int i = pivotPoint - 1 ; i > 0 ; i -- ) { Console . Write ( pre [ i ] + " ▁ " ) ; } for ( int i = pre . Length - 1 ; i >= pivotPoint ; i -- ) { Console . Write ( pre [ i ] + " ▁ " ) ; } Console . Write ( pre [ 0 ] ) ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void countSubstrings ( string s ) { int ans = 0 ; int subs = 1 ; char pre = '0' ; foreach ( char i in s ) { if ( pre == i ) { subs += 1 ; } else { subs = 1 ; } ans += subs ; pre = i ; } Console . WriteLine ( ans ) ; } static void Main ( ) { string s = " geeksforgeeks " ; countSubstrings ( s ) ; } }

Accumulator variables: ans, subs
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class Pair { public int first , second ; public Pair ( int first , int second ) { this . first = first ; this . second = second ; } } public class GFG { static void find_original_array ( List < Pair > A ) { Dictionary < int , List < int > > mp = new Dictionary < int , List < int > > ( ) ; List < int > res = new List < int > ( ) ; Dictionary < int , bool > visited = new Dictionary < int , bool > ( ) ; foreach ( Pair it in A ) { List < int > temp ; temp = ( mp . ContainsKey ( it . first ) ) ? mp [ it . first ] : new List < int > ( ) ; temp . Add ( it . second ) ; if ( ! mp . ContainsKey ( it . first ) ) mp . Add ( it . first , temp ) ; else mp [ it . first ] = temp ; temp = ( mp . ContainsKey ( it . second ) ) ? mp [ it . second ] : new List < int > ( ) ; temp . Add ( it . first ) ; if ( ! mp . ContainsKey ( it . second ) ) mp . Add ( it . second , temp ) ; else mp [ it . second ] = temp ; } int It = 0 ; foreach ( int key in mp . Keys ) { if ( mp [ key ] . Count == 1 ) { It = key ; } } int adjacent = It ; res . Add ( It ) ; visited . Add ( It , true ) ; while ( res . Count != A . Count + 1 ) { foreach ( int elements in mp [ adjacent ] ) { if ( ! visited . ContainsKey ( elements ) ) { res . Add ( elements ) ; visited . Add ( elements , true ) ; adjacent = elements ; } } } foreach ( int val in res ) { Console . Write ( val + " ▁ " ) ; } } static public void Main ( ) { List < Pair > A = new List < Pair > ( ) ; A . Add ( new Pair ( 5 , 1 ) ) ; A . Add ( new Pair ( 3 , 4 ) ) ; A . Add ( new Pair ( 3 , 5 ) ) ; find_original_array ( A ) ; } }

Index/key variables: adjacent, key
Iterator variables: elements, it, key, val
Class/struct names: GFG, Pair
C# program:
using System ; class GfG { static void constructTree ( int n , int d , int h ) { if ( d == 1 ) { if ( n == 2 && h == 1 ) { Console . WriteLine ( "1 ▁ 2" ) ; return ; } Console . WriteLine ( " - 1" ) ; return ; } if ( d > 2 * h ) { Console . WriteLine ( " - 1" ) ; return ; } for ( int i = 1 ; i <= h ; i ++ ) Console . WriteLine ( i + " ▁ " + ( i + 1 ) ) ; if ( d > h ) { Console . WriteLine ( "1" + " ▁ " + ( h + 2 ) ) ; for ( int i = h + 2 ; i <= d ; i ++ ) { Console . WriteLine ( i + " ▁ " + ( i + 1 ) ) ; } } for ( int i = d + 1 ; i < n ; i ++ ) { int k = 1 ; if ( d == h ) k = 2 ; Console . WriteLine ( k + " ▁ " + ( i + 1 ) ) ; } } public static void Main ( String [ ] args ) { int n = 5 , d = 3 , h = 2 ; constructTree ( n , d , h ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GfG